Re: Kernel in D

2014-06-05 Thread 1100110 via Digitalmars-d-learn

On 5/31/14, 7:57, ed wrote:

On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:

So, I've gotten interested in kernel programming in D.. And as much as
I like C/C++, I wanna try innovating, I'm aware that phobos/gc and any
OS-specific issues are going to be a problem, but I'm willing to
implement them into the kernel itself.

So, I guess what I'm asking is this: What should I look out for, what
should I avoid, and what should I use to my advantage?

I'm not expecting this kernel to be Linux right off the bat, but I
would like to see how far D can go with this.

Any ideas? :P


I wrote a little kernel a while back that all started when I read this
wiki page:

http://wiki.osdev.org/D_Bare_Bones

You may be beyond this already as it is pretty basic stuff...still it's
good if you're just learning like I am. There are some articles that
helped me fix the 64-bit bootloader issues I was having as well.

Cheers,
ed



Just a warning, there are a few bugs on that wiki page.  Nothing major, 
just don't expect every example to work out of the box. (unless it has 
been  updated in the last year of course).


I thought about editing it, but I lost interest in my project before I 
got around to it. =C


I've long since forgotten what issues I encountered though...


Re: Kernel in D

2014-06-05 Thread 1100110 via Digitalmars-d-learn

On 6/5/14, 6:05, 1100110 wrote:

On 5/31/14, 7:57, ed wrote:

On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote:

So, I've gotten interested in kernel programming in D.. And as much as
I like C/C++, I wanna try innovating, I'm aware that phobos/gc and any
OS-specific issues are going to be a problem, but I'm willing to
implement them into the kernel itself.

So, I guess what I'm asking is this: What should I look out for, what
should I avoid, and what should I use to my advantage?

I'm not expecting this kernel to be Linux right off the bat, but I
would like to see how far D can go with this.

Any ideas? :P


I wrote a little kernel a while back that all started when I read this
wiki page:

http://wiki.osdev.org/D_Bare_Bones

You may be beyond this already as it is pretty basic stuff...still it's
good if you're just learning like I am. There are some articles that
helped me fix the 64-bit bootloader issues I was having as well.

Cheers,
ed



Just a warning, there are a few bugs on that wiki page.  Nothing major,
just don't expect every example to work out of the box. (unless it has
been  updated in the last year of course).

I thought about editing it, but I lost interest in my project before I
got around to it. =C

I've long since forgotten what issues I encountered though...



I should also clarify that I'm just a novice and really just wanted 
insight into how it all worked.  So anyone more experienced might simply 
know something that I did not.


Re: What does q{...} mean?

2014-02-24 Thread 1100110

On 2/24/14, 11:06, Gary Willoughby wrote:

On Monday, 24 February 2014 at 11:53:00 UTC, anonymous wrote:

On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote:

On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote:

I keep seeing this syntax used a bit and i'm stumped to what it
means. What is it?

enum foo = q{
 // ???
};


http://dlang.org/lex.html#DelimitedString


It's a token string though, not a delimited string. See the
section Token Strings on that page.


What are they used for? Simpler for creating code at compile time?


It allows IDE syntax highlighting and code completion to work with 
strings that are going to be mixed in.


You don't have to use it, in fact there's no difference between this and 
a normal string.


It's just nicer.


Re: What does q{...} mean?

2014-02-24 Thread 1100110

On 2/24/14, 12:40, monarch_dodra wrote:


Also, a qstring can only contain valid D tokens (token string). If
your mixin string does not adhere some the base D syntaxic rules, you'll
get a compilation error. In particular, you'll need balanced
bracing/parenthesising, and correctly formed tokens.


Oh, I did not know that.  Interesting.


Re: Begining with D

2013-10-12 Thread 1100110

On 10/10/2013 02:36 PM, Adam D. Ruppe wrote:

On Thursday, 10 October 2013 at 19:19:53 UTC, Ali Çehreli wrote:

import std.c.linux.termios;


worth noting that this is Linux only. doing it on Windows is a little
different.

Working with console/terminal input and output can get surprisingly
complex, and doing it cross-platform is easiest with a library.

Robik's consoleD is one:
https://github.com/robik/ConsoleD/blob/master/consoled.d

it focuses on enabling color and drawing mainly, and also has functions
to turn off the line buffering and getch().

If you use his library, you can do this:

import consoled;

void main() {
 int a = getch(); // gets just one character
 writecln(a); // prints back out what you got
}

and other nice things.


I had issues with getch() on ConsoleD...

If you too have issue, you can try 
github.com/D-Programming-Deimos/ncurses which has similar functions, but 
is also way more complex...


Re: Linking Trouble (Linux)

2013-09-29 Thread 1100110

https://xkcd.com/979/

Please.  You are somebodies hero.


Re: Tips on making regex more performant?

2013-06-18 Thread 1100110

On 06/18/2013 01:53 PM, Gary Willoughby wrote:

Below is an example snippet of code to test for performance of regex
matches. I need to parse a large log and extract data from it and i've
noticed a huge increase in time of the loop when reading and using regex.

 ...
 auto alert = regex(r^Alert ([0-9]+));

 while ((line = file.readln()) !is null)
 {
 auto m = match(line, alert);

 if (m)
 {
 alerts++;
 }

 counter++;
 }
 ...

Using the above example i parse about 700K lines per second (i'm reading
from an SSD). If i comment out the regex match function, i read at 4.5M
lines per second. Considering i need to use about 8 regex matches and
extract data, this figure further drops to about 100K lines per second.

Is there anything i can do to speed up regex matching in such a
scenario? Are there any tips you can share to speed things up?

Thanks.


enum alert = ctRegex!r^Alert ([0-9]+);

And then use it the same way.


Re: Compiler bug ?

2013-05-17 Thread 1100110
On 05/17/2013 09:35 AM, Maxim Fomin wrote:
 On Friday, 17 May 2013 at 14:12:10 UTC, Namespace wrote:
 I don't see where k comes from?
 
 I think the point is that it comes from nowhere. Compiler incorectly
 omits two errors from output: Error undefined indentifier and
 template instance error instantiation. This should go to bugzilla.
 
 And it's always a bad idea to prefix a variable with '__', because
 this is reserved to the compiler.
 
 If it alwalys a bad idea, compiler should not accept such code.

It is not the D way to forbid you from shooting yourself in the foot.

goto, catch(Throwable th), there are plenty more examples.



signature.asc
Description: OpenPGP digital signature


Re: Compiler bug ?

2013-05-17 Thread 1100110
On 05/17/2013 12:27 PM, Jonathan M Davis wrote:
 On Friday, May 17, 2013 19:19:46 bearophile wrote:
 I think to answer this issue we need someone that knows more
 about the DMD compiler (as Kenji Hara). I think that if we want
 to forbid those variables in user code, then probably there is a
 way do to it.
 
 Oh, I'm sure that it would be possible. It's just a question of how 
 complicated that would be and whether it's worth it given that very few 
 programmers try and declare variables which start with two underscores.
 
 - Jonathan M Davis


I love how we are all basically agreeing with one another, even though
we are saying such different things.



signature.asc
Description: OpenPGP digital signature


Re: Getting byte size of POD classes and dynamic arrays

2013-05-16 Thread 1100110
On 05/16/2013 08:09 AM, Byron Heads wrote:
 I am working on d-leveldb wrapper (https://github.com/bheads/d-leveldb) 
 and I need to be able to pass blocks of data between D and leveldb API.
 I am having rouble getting the byte size of dynamic arrays and POD 
 classes.
 
 I can get the right size for 1D dynamic arrays, need a way to compute the 
 total size.
 
 POD Classes always give me the size of the ref, is it possible?
 
 -Byron


__traits(classInstanceSize, MyClass); ?



signature.asc
Description: OpenPGP digital signature


Re: Getting byte size of POD classes and dynamic arrays

2013-05-16 Thread 1100110
On 05/16/2013 08:21 AM, Byron Heads wrote:
 On Thu, 16 May 2013 08:11:35 -0500, 1100110 wrote:
 
 On 05/16/2013 08:09 AM, Byron Heads wrote:
 I am working on d-leveldb wrapper (https://github.com/bheads/d-leveldb)
 and I need to be able to pass blocks of data between D and leveldb API.
 I am having rouble getting the byte size of dynamic arrays and POD
 classes.

 I can get the right size for 1D dynamic arrays, need a way to compute
 the total size.

 POD Classes always give me the size of the ref, is it possible?

 -Byron


 __traits(classInstanceSize, MyClass); ?
 
 I missed that one, in my test it returns 29 bytes,
 8 for __vptr
 8 for __monitor
 13 for data
 
 now I am wondering way a POD has a vtable.  Either way its not safe to 
 store a byte copy in to leveldb

Why not just use a struct?  .sizeof gives those accurately.  Oh you
wanted both...

Maybe take a look at vibe's rest interface?  It extracts the members of
classes and does funny things with them.  Can't say I understand it.
Over my head...

https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/rest.d

or
final class MyPodClass {} ?

And yeah, if you get stuck, std.traits is a really rich resource. =D


Good luck!



signature.asc
Description: OpenPGP digital signature


Re: delegates and temporary struct

2013-05-16 Thread 1100110
On 05/16/2013 09:21 PM, Maxim Fomin wrote:
 On Thursday, 16 May 2013 at 22:53:56 UTC, Jack Applegame wrote:
 Look at this code:
 import std.stdio;

 class Foo {
 int value = 123456;
 }

 struct Bar {
 this(Foo f) { foo = f; }
 @property auto lambda() {
   return (){ writefln(value = %s, foo.value); };
 }
 Foo foo;
 }
 auto getLambda(Foo f) {
 return Bar(f).lambda; // lambda closure points to temporary Bar on
 the stack
 }
 void main() {
 Foo foo = new Foo;
 auto lambda = getLambda(foo);
 lambda(); // undefined behaviour? prints some number, but not 123456
 }
 It compiles, but result is unpredictable.

 Platform: Windows 7, dmd 2.062

 For reproducing this behaviour it's necessary to omit -inline and -O
 flags, try simple rdmd test.d
 
 http://d.puremagic.com/issues/show_bug.cgi?id=9352

I get an incorrect but consistent number using dmd -m32 test.d and the
correct number using dmd -m64 test.d on Linux.



signature.asc
Description: OpenPGP digital signature


Re: File I/O - rawWrite issues

2013-05-15 Thread 1100110
On 05/08/2013 07:29 PM, H. S. Teoh wrote:
 
 No need to be embarrassed; it happens to the best of us. IME, some of
 the most frustrating, hair-pulling bugs that take hours (or days!) to
 get to the bottom of often turn out to be dead-easy trivial mistakes
 that got overlooked because they were *too* obvious.

+1

I'm not even going to mention the times that one simply forgets to
recompile...  Now _that's_ embarrassing.



signature.asc
Description: OpenPGP digital signature


Re: C to D conversion for function

2013-04-29 Thread 1100110
On 04/29/2013 06:50 AM, Timon Gehr wrote:
 On 04/29/2013 12:57 PM, Sumit Raja wrote:
 Hi,

 I wanted some help in converting this

 void av_log_ask_for_sample(void *avc, const char *msg, ...)
 av_printf_format(2, 3);

 from C to D.

 I don't know what it means or is called in C to start with so I am a bit
 lost on what to search for.

 Thanks

 Sumit
 
 av_printf_format is a preprocessor macro that expands to a built-in
 compiler attribute which enables compile-time printf-style format string
 checking. There is no support for such a feature in any D compiler.
 
 You want
 
 void av_log_ask_for_sample(void* avc, const(char)* msg, ...);
 
 
 In case you want to preserve the attribute:
 
 struct av_printf_format{ int fmtpos, attrpos; }
 
 @av_printf_format(2, 3) void av_log_ask_for_sample(void* avc,
 const(char)* msg, ...);
 

What is the difference between const(char)*, and const(char*)?  I have
seen them used pretty much interchangeably...

Are they? Somehow I don't think they are.


Re: Status of AA's?

2013-03-30 Thread 1100110

On 03/29/2013 02:43 AM, Dmitry Olshansky wrote:

29-Mar-2013 00:54, 1100110 пишет:

On 03/28/2013 03:05 PM, Dmitry Olshansky wrote:


The built-in ones are a minefield for anything more complex then a
dictionary of string-int :)


Please, last I checked, they were still a minefield for that...
Random crashes, basic issues with the type system...


I just stopped using them...
But that's not very helpful.

So if someone wants to tell me what I can do to help fix it, I'll do
whatever I can.

Just... ya know. order me around and such.


Enlist yourself as a trooper for H.S. Teoh's squad of the New AA
implementation :)

Basically I'd wish to help him (and others) finalize it but have no time
to spent.



I'll look into it.  Thanks


Re: Status of AA's?

2013-03-28 Thread 1100110

On 03/28/2013 03:05 PM, Dmitry Olshansky wrote:


The built-in ones are a minefield for anything more complex then a
dictionary of string-int :)


Please, last I checked, they were still a minefield for that...
Random crashes, basic issues with the type system...


I just stopped using them...
But that's not very helpful.

So if someone wants to tell me what I can do to help fix it, I'll do 
whatever I can.


Just...  ya know.  order me around and such.


Re: How to catenate a string multiple times ?

2013-03-16 Thread 1100110

On 03/16/2013 10:29 AM, Peter Sommerfeld wrote:

Cannot find a reference: What is the best way
to catenate a string multiple times ?
Unfortunately this this does not work ;-)

string tab = ..;
tab = tab * 4; // - 

Peter

foreach(0..4)
write(...);


Re: How to catenate a string multiple times ?

2013-03-16 Thread 1100110

On 03/16/2013 10:39 AM, 1100110 wrote:

On 03/16/2013 10:29 AM, Peter Sommerfeld wrote:

Cannot find a reference: What is the best way
to catenate a string multiple times ?
Unfortunately this this does not work ;-)

string tab = ..;
tab = tab * 4; // - 

Peter



foreach(0..4)

write(...);


or
str = str ~ ...;

I shoulda proofread that.


Re: make a nothrow call a throwing function

2013-02-07 Thread 1100110

On 02/07/2013 05:38 AM, monarch_dodra wrote:

On Thursday, 7 February 2013 at 10:55:26 UTC, Jonathan M Davis wrote:

On Thursday, February 07, 2013 11:06:14 monarch_dodra wrote:

Is there any way that a nothrow function can call a function that
throws, but without even trying to catch if an exception is
thrown?

My use case is a pretty low level nothrow function, that needs to
call something that never ever throws, but was not marked as such.

I want to avoid the try/catch/[do nothing|assert] because I
don't want to pay for that. Ideally, i'd really just want to mark
my function as nothrow, and have undefined behavior if it *does*
throw.

Any way to do that?


You can cast the function.

- Jonathan M Davis


Smart.

Unfortunatly, in this case, I'm trying to call string.dup.

It would appear though that (apparently), dup is a property that returns
a function pointer, or something. In any case, I can't seem to be able
to get its address.

Now I feel kind of bad for suggesting banning taking the address of a
property function ...

I can bypass this with a wrapper function I guess, but at this point,
I'd have to bench to see if that is even worth it...


scope(failure) has worked for me in the past, but mostly calling C 
functions from nothrow.


You do have to put it at the top of the function, but it's simple and nice.


Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread 1100110

On 01/14/2013 02:03 AM, Timon Gehr wrote:

On 01/14/2013 07:26 AM, 1100110 wrote:

On 01/13/2013 11:35 PM, 1100110 wrote:

Ok, I wish to create a standard timing system so that I can measure ~how
long each function takes to execute.

I wish to be able to place at the start of a function
version(Time) mixin TimeExecution(funcName);

mixin template TimeExecution(T) if(isSomeString!T) {
import std.stdio, std.datetime, std.conv;

auto sw = StopWatch(AutoStart.yes);
// Error: Declaration expected, not '('
scope(exit) writeln(T, : , to!Duration(sw.peek));
}


Why do I receive the Error when the scope statement is included?
Is this an error, or what is the rationale behind the decision?

Thank you.


It appears that you cannot mixin *any* statement with
scope([exit,success,etc]) in it.

I have been rereading my copy of TDPL, and it states that mixin
statements must be valid D code, and there can be multiple 'scope()'
statements.

Since scope(exit) writeln(); is valid D code, and refuses to compile
in a mixin, I assume that this is a bug.

I've been digging through the bug tracker and I cannot find a duplicate
bug, so if someone can confirm that this is a bug, I'll create a report.


It is not a bug. Use a string mixin.


Well, dangit.  Thanks!


Re: Good tutorials

2013-01-14 Thread 1100110

On 01/14/2013 12:25 PM, SaltySugar wrote:

Where i can find some good tutorials and books? :)


https://github.com/PhilippeSigaud/D-templates-tutorial

https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.pdf?raw=true

The second link is a direct pdf download of the tutorial.

I find it's quite nice.


Re: Processes

2013-01-13 Thread 1100110

On 01/13/2013 08:01 AM, Tomas wrote:

Hey, guys.

I need to get all running processes list, and kill one. (example: Find
all processes and if skype.exe is running, kill it.)


---
import std.stdio;
import std.process;

//assuming we want to kill htop
void main() {
killProcess(htop);
}

void killProcess(string n){
version(linux) {
auto processNumber = shell(pgrep ~ n);
writeln(n ~ process number is: ~processNumber);

shell(kill ~ processNumber);
writeln(n ~ has been killed.);
}

version(Windows) {// I don't know windows enough, your turn.

}
}
---

I assume it would be similar on Windows, since you will need to go 
through the OS in any case, but this is a simple, hastily written 
example since no one else has answered.


Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110
Ok,  I wish to create a standard timing system so that I can measure 
~how long each function takes to execute.


I wish to be able to place at the start of a function
version(Time) mixin TimeExecution(funcName);

mixin template TimeExecution(T) if(isSomeString!T) {
import std.stdio, std.datetime, std.conv;

auto sw = StopWatch(AutoStart.yes);
//  Error: Declaration expected, not '('
scope(exit) writeln(T, : , to!Duration(sw.peek));
}


Why do I receive the Error when the scope statement is included?
Is this an error, or what is the rationale behind the decision?

Thank you.


Re: Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110

On 01/13/2013 11:35 PM, 1100110 wrote:

Ok, I wish to create a standard timing system so that I can measure ~how
long each function takes to execute.

I wish to be able to place at the start of a function
version(Time) mixin TimeExecution(funcName);

mixin template TimeExecution(T) if(isSomeString!T) {
import std.stdio, std.datetime, std.conv;

auto sw = StopWatch(AutoStart.yes);
// Error: Declaration expected, not '('
scope(exit) writeln(T, : , to!Duration(sw.peek));
}


Why do I receive the Error when the scope statement is included?
Is this an error, or what is the rationale behind the decision?

Thank you.


It appears that you cannot mixin *any* statement with 
scope([exit,success,etc]) in it.


I have been rereading my copy of TDPL, and it states that mixin 
statements must be valid D code, and there can be multiple 'scope()' 
statements.


Since scope(exit) writeln(); is valid D code, and refuses to compile 
in a mixin, I assume that this is a bug.


I've been digging through the bug tracker and I cannot find a duplicate 
bug, so if someone can confirm that this is a bug, I'll create a report.


Re: telnet and D

2012-11-28 Thread 1100110

On 11/27/2012 01:56 PM, maarten van damme wrote:

Haven't looked at vibe.d yet because it looked more like a library for
writing web apps and  normal sockets should be enough.


Didn't know about Tango, I'll try deciphering the original d1 module.


... I mean no offense, but that sounds painful.

vibe.d is very modular, just import what you need.
I hate to push it, but it has very good documentation and examples.

Its designed for web apps, but it makes a nice little web library as well.

import vibe.vibe;

void main()
{
auto client = new HttpClient;
client.connect(www.google.com, 80);

auto res = client.request((req){
req.url = /;
});

logInfo(Response: %d, res.statusCode);

foreach( k, v; res.headers )
logInfo(Header: %s: %s, k, v);

(new NullOutputStream).write(res.bodyReader);
client.disconnect();
}




Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread 1100110

On 11/28/2012 12:57 PM, Dmitry Olshansky wrote:

11/28/2012 10:51 PM, Ali Çehreli пишет:

A friend of mine reports that the memory usage of the following program
grows continuously when compiled with dmd 2.060 and run on Windows 7 sp1
home premium 64 bit (also on Microsoft Windows [Version 6.1.7600]).

If you are on Windows, could you please say whether you have the same
problem. (I don't have Windows.) The following is how we reproduce:


[snip]


The program gets terminated by a core.exception.OutOfMemoryError. (Same
problem with std.stream.BufferedFile.)


Same here on more or less fresh 2.061. About 12 iterations. Win8 x64
running 32-bit app.




Isn't this a known problem with a conservative GC on 32bit?  The GC sees 
something that *Could* be a reference, and refuses to collect that data.


Re: Apparent problem with GC not collecting on Windows

2012-11-28 Thread 1100110

On 11/28/2012 02:53 PM, Ali Çehreli wrote:

On 11/28/2012 11:11 AM, 1100110 wrote:
  On 11/28/2012 12:57 PM, Dmitry Olshansky wrote:
  11/28/2012 10:51 PM, Ali Çehreli пишет:
  A friend of mine reports that the memory usage of the following
program
  grows continuously when compiled with dmd 2.060 and run on Windows
7 sp1
  home premium 64 bit (also on Microsoft Windows [Version 6.1.7600]).
 
  If you are on Windows, could you please say whether you have the same
  problem. (I don't have Windows.) The following is how we reproduce:
 
  [snip]
 
  The program gets terminated by a core.exception.OutOfMemoryError.
(Same
  problem with std.stream.BufferedFile.)
 
  Same here on more or less fresh 2.061. About 12 iterations. Win8 x64
  running 32-bit app.
 
 
 
  Isn't this a known problem with a conservative GC on 32bit? The GC sees
  something that *Could* be a reference, and refuses to collect that data.

I think it is more like an integer value looking like a pointer to
something. I don't see what the GC may be confused with in this case.

I've still created a bug:

http://d.puremagic.com/issues/show_bug.cgi?id=9094

Ali



That's what I meant. =P


Re: telnet and D

2012-11-26 Thread 1100110

On 11/26/2012 04:58 PM, maarten van damme wrote:

I was wondering if there ever was a telnet library written for D? I've
been unable to find anything. I also tried using curl but the timeout
options seem to fail here. I've tried writing a minimalistic client
myself but the library will be used to connect to some routers and
either something is wrong in my option negotiation or that router
doesn't support the full telnet protocol.

I can't use socketstreams because it strangely counts 255 as a
newline and I'm afraid it'll mess things up when I try to send
different data and socketstream is going to be deprecated...


Have you taken a look at vibe.d? http://vibed.org

IIRC, telnet is simple, so it shouldn't be too difficult..


Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-12 Thread 1100110




Yeah. Though note that 1000 bug reports are from bearophile.


Well, at least he's persistent.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: long compile time question

2012-10-23 Thread 1100110

On Tue, 23 Oct 2012 22:50:46 -0500, Dan dbdavid...@yahoo.com wrote:


The following takes nearly three minutes to compile.
The culprit is the line bar ~= B();
What is wrong with this?

Thanks,
Dan

struct B {
   const size_t SIZE = 1024*64;
   int[SIZE] x;
}

void main() {
   B[] barr;
   barr ~= B();
}
-

I have the same issue on linux x64 2.060

So appending to a dynamic array isn't really that efficient.
But this goes WAY over that line.  I'm timing your test now.

It's still going...


--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Deimos organization

2012-10-21 Thread 1100110

On Sun, 21 Oct 2012 00:52:02 -0500, Matt Soucy mso...@csh.rit.edu wrote:

I've been messing around with Deimos lately, and I was a little bit  
confused about some of the design.
I saw that a couple (ZeroMQ, ncurses) didn't follow the usual structure  
of having a c/ and a deimos/ folder. Is this by design, or is it  
something that should be remedied?


Other things I was unsure about:
libmysql, libc, libruby, lua don't have any D files at all - some are  
just READMEs. Are these still under development?
libexif goes libexif/libexif/(d files) instead of  
libexif/deimos/libexif/(d files). Also by design?


Thank you,
Matt

ncurses is mine, Just tell me how you'd like it to change, and I'll fix it.

I've been meaning to fix that at some point...

I'm willing to manually bind one of those empty repos, but I understand  
that there has been quite a lot of interest in using dstep to automate the  
binding process completely.  Shrugs.  It seems to me its languishing in  
hopes of an automated tool.


--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Deimos organization

2012-10-21 Thread 1100110



Other things I was unsure about:
libmysql, libc, libruby, lua don't have any D files at all - some are  
just READMEs. Are these still under development?
libexif goes libexif/libexif/(d files) instead of  
libexif/deimos/libexif/(d files). Also by design?


Let me amend that. I won't do libc.  Too much preprocessor crap.
--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: read single characters from stdin

2012-09-28 Thread 1100110
On Wed, 26 Sep 2012 13:06:03 -0500, Adam D. Ruppe  
destructiona...@gmail.com wrote:



On Wednesday, 26 September 2012 at 17:51:03 UTC, Thomas Koch wrote:

How can I read single characters?


The way I'd do it is with the C call fgetc(stdin). You can do it in D  
the same way if you import core.stdc.stdio;


But, if you are on Linux, it isn't going to be that simple. The Linux  
terminal/operating system will buffer input, not sending any data to you  
until the user presses enter.


You'll probably want to use a library like ncurses on linux... you can  
do without too, turning on raw mode to the terminal I think, but I don't  
remember how to do it right now. Are you on Linux or Windows?


(I'm pretty sure it just works on windows but it's been a while since  
I've done an app like this.)



ncurses will do it with getch().
pdpurses should have the same function.

You will most likely still have to ncurses setup and teardown though.  
shrug.


Re: Memory detection

2012-08-24 Thread 1100110
On Fri, 24 Aug 2012 15:42:21 -0500, Dmitry Olshansky  
dmitry.o...@gmail.com wrote:



On 24-Aug-12 07:03, 1100110 wrote:


On linux this is not so difficult to do.

Those values are generally in /proc, and it seems to be portable across
pretty much every distro with a relatively recent kernel.

I have an extremely half-assed bit of code that prints the load average
and the totaly % of mem used to my tmux session.
It gives the exact same values that are seen in top, or htop.(without
the overhead of parsing their output, cause that takes ~500ms, way too
slow.)


If parsing takes 500ms then something is seriously wrong. What is size  
of the input to parse and the machine specs?




No, you misunderstand.

Parsing the output of the `top` command takes ~500ms.

The snippet of code that reads /proc directly takes an order of magnitude  
less time.


I assume that top reads several times, and also reads the percentages of  
each process that is running, while I only

read the load average and total memory consumption.

The vast majority of the time spent parsing `top` was spent waiting for it  
to initialize, and print the values to be read.


TL;DR
Parsing was probably the wrong word to use.

Reading from /proc directly will take an order of magnitude less time.


--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Memory detection

2012-08-24 Thread 1100110
On Fri, 24 Aug 2012 16:05:28 -0500, Dmitry Olshansky  
dmitry.o...@gmail.com wrote:



On 25-Aug-12 00:52, 1100110 wrote:

On Fri, 24 Aug 2012 15:42:21 -0500, Dmitry Olshansky
dmitry.o...@gmail.com wrote:


On 24-Aug-12 07:03, 1100110 wrote:


On linux this is not so difficult to do.

Those values are generally in /proc, and it seems to be portable  
across

pretty much every distro with a relatively recent kernel.

I have an extremely half-assed bit of code that prints the load  
average

and the totaly % of mem used to my tmux session.
It gives the exact same values that are seen in top, or htop.(without
the overhead of parsing their output, cause that takes ~500ms, way too
slow.)


If parsing takes 500ms then something is seriously wrong. What is size
of the input to parse and the machine specs?



No, you misunderstand.

Parsing the output of the `top` command takes ~500ms.

Then it's not parsing but the it's time to spawn process that does a  
fuckton of syscalls and read its output through the pipe :)

I just cringed at:
the overhead of parsing their output, cause that takes ~500ms


The snippet of code that reads /proc directly takes an order of
magnitude less time.

I assume that top reads several times, and also reads the percentages of
each process that is running, while I only
read the load average and total memory consumption.

The vast majority of the time spent parsing `top` was spent waiting for
it to initialize, and print the values to be read.

TL;DR
Parsing was probably the wrong word to use.



Yes, sorry for being nit-picky.


Reading from /proc directly will take an order of magnitude less time.



And yes.


size_t memTotal, memUsed;
Stream memInfo  = new BufferedFile(/proc/meminfo);
auto t  = memInfo.readLine();
memTotal= to!size_t(strip(t[9..$-3]));
memUsed = memTotal;

auto f  = memInfo.readLine();
memUsed -= to!size_t(strip(f[8..$-3]));

auto c = memInfo.readLine();
memUsed -= to!size_t(strip(c[8..$-3]));

auto b = memInfo.readLine();
memUsed -= to!size_t(strip(b[8..$-3]));

memInfo.close();

Fair warning, I wrote this over the course of 5 minutes by directly  
translating some public domain code.

It works, so I've never bothered to clean it up.

But that'll give you the total memory used, and the total amount of memory.
--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Memory detection

2012-08-23 Thread 1100110
On Thu, 23 Aug 2012 18:37:59 -0500, bearophile bearophileh...@lycos.com  
wrote:



Charles Hixson:

Is it possible to detect when a program is using, say, 90% of the  
memory that is available, so that I can take steps to reduce usage?


With computers that have virtual memory this is not so easy to do. I  
think you have to use operating system-specific code to ask the OS about  
the physical available memory, about the virtual memory used, the rate  
of virtual memory swapping, and use those three values in some way.


Bye,
bearophile


On linux this is not so difficult to do.

Those values are generally in /proc, and it seems to be portable across  
pretty much every distro with a relatively recent kernel.


I have an extremely half-assed bit of code that prints the load average  
and the totaly % of mem used to my tmux session.
It gives the exact same values that are seen in top, or htop.(without the  
overhead of parsing their output, cause that takes ~500ms, way too slow.)

It would make a decent starting point at least.

I would imagine that you wouldn't even need to know the % of memory YOUR  
program is using, just the general percentage overall.


After all, no matter who is eating all the memory, shit's about to hit the  
fan if *someone* doesn't free some memory.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: -noboundscheck

2012-08-19 Thread 1100110

I have gdc, dmd, and ldc installed on my computer.

I also forked your repo two minutes before reading this.


Tell me what you want, and Ill run whatever tests you want.
But in return, I'm stealing your whirlpool.(with attribution of course.)


Re: -noboundscheck

2012-08-19 Thread 1100110

Yeah, I figured it out.  I did have to rename src though...

I ran a few tests, inconclusive for any serious difference.
gdc is now compiling with -O3 -march=native -frelease -fno-bounds-check  
-finline -ffast-math.


But no, dmd has the shortest compile times, gdmd the longest.
I'm timing everything right now.

...My laptop is getting hot...

I want to see how bad it crashes.  =P
On Sun, 19 Aug 2012 17:17:02 -0500, Nvirjskly nvirjs...@gmail.com wrote:


On Sunday, 19 August 2012 at 21:11:13 UTC, 1100110 wrote:

I have gdc, dmd, and ldc installed on my computer.

I also forked your repo two minutes before reading this.


Tell me what you want, and Ill run whatever tests you want.
But in return, I'm stealing your whirlpool.(with attribution of course.)


Haha I actually do not have whirlpool implemented yet (it's an empty  
file,) but since you seem to want it, it's right at the top of my TODO  
list (if I'm lucky I'll get it done by the end of today, but best bet is  
this time tomorrow. I already have the spec open.)


benchmark.d contains a main function  that runs some rudimentary  
benchmarks if you want to compile it with that...


import std.process, std.stdio, std.file, std.path;
void main()
{
  string files = ;
  foreach (string name; dirEntries(src, SpanMode.breadth))
  {
   if(name.isFile())
   files ~= name ~  ;
  }
  string command = dmd  ~ files ~ benchmark.d -ofcryptod  
-noboundscheck -O -release -inline;

  writeln(shell(command));
}

should compile that with dmd, I'm not sure about ldc or gdc and their  
compiler options, but it should be something similar...



--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: -noboundscheck

2012-08-19 Thread 1100110
Here are my results! iirc -release implies -noboundscheck..Also I am on x64, and these files only compile to 32bit. So there could be performance missing there.rdmd --force -I../ -m32 -O -inline -release benchmark.d  26.00s user 0.23s system 99% cpu 26.386 total---2048 md2 in 1003 milliseconds: 15.9521 Mib/s32768 md4 in 682 milliseconds: 375.367 Mib/s32768 md5 in 426 milliseconds: 600.939 Mib/s8192 ripemd160 in 779 milliseconds: 82.1566 Mib/s4096 sha1 in 276 milliseconds: 115.942 Mib/s16777216 ints generated by mersenne twister in 1146 milliseconds: 446.771 Mib/s256 ints generated by BlumBlumShub in 812 milliseconds: 0.00962131 Mib/s1048576 texts blowfish encrypted in 645 milliseconds: 99.2248 Mib/s65536 texts threefish encrypted in 2774 milliseconds: 5.76784 Mib/s131072 texts AES128 encrypted in 896 milliseconds: 17.8571 Mib/srdmd --force -I../ -m32 benchmark.d  16.79s user 0.19s system 99% cpu 17.048 total---2048 md2 in 1546 milliseconds: 10.3493 Mib/s32768 md4 in 1240 milliseconds: 206.452 Mib/s32768 md5 in 1558 milliseconds: 164.313 Mib/s8192 ripemd160 in 1535 milliseconds: 41.6938 Mib/s4096 sha1 in 616 milliseconds: 51.9481 Mib/s16777216 ints generated by mersenne twister in 1510 milliseconds: 339.073 Mib/s256 ints generated by BlumBlumShub in 816 milliseconds: 0.00957414 Mib/s1048576 texts blowfish encrypted in 1094 milliseconds: 58.5009 Mib/s65536 texts threefish encrypted in 3316 milliseconds: 4.82509 Mib/s131072 texts AES128 encrypted in 1945 milliseconds: 8.22622 Mib/s(ldc  gdc REALLY hate building 32bit code...)rdmd --compiler=ldmd2 --force -I../ -m32 -O -release -noboundscheck benchmark.d2048 md2 in 570 milliseconds: 28.0702 Mib/s32768 md4 in 765 milliseconds: 334.641 Mib/s32768 md5 in 840 milliseconds: 304.762 Mib/s8192 ripemd160 in 571 milliseconds: 112.084 Mib/s4096 sha1 in 263 milliseconds: 121.673 Mib/s16777216 ints generated by mersenne twister in 747 milliseconds: 685.408 Mib/score.exception.AssertError@/build/src/ldc-build/runtime/phobos/std/internal/math/biguintcore.d(2044): Assertion failurereal0m8.957suser0m8.499ssys 0m0.387srdmd --compiler=ldmd2 --force -I../ -m32 benchmark.d2048 md2 in 2680 milliseconds: 5.97015 Mib/s32768 md4 in 2088 milliseconds: 122.605 Mib/s32768 md5 in 2465 milliseconds: 103.854 Mib/s8192 ripemd160 in 2051 milliseconds: 31.2043 Mib/s4096 sha1 in 742 milliseconds: 43.1267 Mib/s16777216 ints generated by mersenne twister in 1580 milliseconds: 324.051 Mib/score.exception.AssertError@/build/src/ldc-build/runtime/phobos/std/internal/math/biguintcore.d(2044): Assertion failurereal0m14.722suser0m14.412ssys 0m0.230sI think gdc died...binary/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1dversion   v2.059parse benchmarkimportall benchmarkimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportsemantic  benchmarkimportimportsemantic2 benchmarksemantic3 benchmarkimportimportcode  benchmark/usr/bin/ld: cannot find -lgphobos2collect2: error: ld returned 1 exit statusreal0m15.950suser0m15.629ssys 0m0.190sI managed to force dmd and (partial) ldc builds for -m64rdmd --force -O -m64 -release -noboundscheck -I../ benchmark.d  14.29s user 0.19s system 99% cpu 14.553 total2048 md2 in 1026 milliseconds: 15.5945 Mib/s32768 md4 in 737 milliseconds: 347.354 Mib/s32768 md5 in 1078 milliseconds: 237.477 Mib/s8192 ripemd160 in 922 milliseconds: 69.4143 Mib/s4096 sha1 in 309 milliseconds: 103.56 Mib/s16777216 ints generated by mersenne twister in 1079 milliseconds: 474.513 Mib/s256 ints generated by BlumBlumShub in 3661 milliseconds: 0.00213398 Mib/s1048576 texts blowfish encrypted in 593 milliseconds: 107.926 Mib/s65536 texts threefish encrypted in 2376 milliseconds: 6.73401 Mib/s131072 texts AES128 encrypted in 874 milliseconds: 18.3066 Mib/s2048 md2 in 587 milliseconds: 27.2572 Mib/s32768 md4 in 675 milliseconds: 379.259 Mib/s32768 md5 in 752 milliseconds: 340.426 Mib/s8192 ripemd160 in 539 milliseconds: 118.738 Mib/s4096 sha1 in 236 milliseconds: 

Re: -noboundscheck

2012-08-19 Thread 1100110

On Sun, 19 Aug 2012 19:26:34 -0500, Nvirjskly nvirjs...@gmail.com wrote:


On Sunday, 19 August 2012 at 23:48:36 UTC, 1100110 wrote:

Here are my results!  iirc -release implies -noboundscheck..
Also I am on x64, and these files only compile to 32bit. So there could  
be

performance missing there.


Wow, thanks. It looks like ldc2 does not play nice with std.bigint,  
which is all the more reason for me to use my own version. If you want  
to see it run and not assert out, remove benchmark_bbs(); from main() in  
benchamrk.d


std.bigint seems to have a lot of problems as I had to repeatedly mess  
around with things that SHOULD work. I think I should file a few bug  
reports :/


I think GDC is dying because I have scope imports scattered everywhere  
and it might not play nice with those... bah.


So it looks like ldc2 produces somewhat faster code, if not for the fact  
that it did not play nice with std.bigint and that gdc does not follow  
the reference compiler in its support of scope imports... :/


So basically my code is dmd only atm and can be easily converted to  
support ldc2, and maybe gdc if scope imports are the only problem...


On the topic of Whirlpool, I'm almost done a naive non-optimised  
version, and just need to make the S-box mixin.


Really?  that was quick.

I didn't get very far with my attempt.  =P

--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Stringy Weirdness

2012-08-18 Thread 1100110
On Sat, 18 Aug 2012 02:35:06 -0500, Simen Kjaeraas  
simen.kja...@gmail.com wrote:



On Sat, 18 Aug 2012 07:11:38 +0200, 1100110 10equa...@gmail.com wrote:


I haven't been quite able to figure this one out.

string[string][]   Dict;//sure ok.
alias string[string][] dict;//Error

void main()
{
 Dict   = [[Cow:moo ],[Duck:quack]];//cool
 Dict  ~=  [Dog:woof]   //No  
prob.
assert(Dict==[[Cow:moo],[Duck:quack],[Dog:woof]]);//looks  
legit

 dict temp  = [[Cow:moo ],[Duck:quack]];//Error
 string[string][] temp2 = [[Cow:moo ],[Duck:quack]];//Error


 //And My favorite one of all:
 auto temp2 = [[Cow:moo],[Duck:quack]];  //Error
}

I've hit stuff like this before, and I've always assumed it was just  
karma for screwing with it.  I can't figure out why it does this.


These are definite bugs. Please file:

http://d.puremagic.com/issues/enter_bug.cgi



Is it supposed to do that or not?  that's what I can't decide...  =P

It doesn't seem to like templates either.  A tls variable, Tuple, or a  
Variant seems to be the only way that

string[string][] works.  It wants a double?  a number anyways.


--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Stringy Weirdness

2012-08-18 Thread 1100110

Issue 8557 has been added to the database




On Sat, 18 Aug 2012 02:35:06 -0500, Simen Kjaeraas  
simen.kja...@gmail.com wrote:



On Sat, 18 Aug 2012 07:11:38 +0200, 1100110 10equa...@gmail.com wrote:


I haven't been quite able to figure this one out.

string[string][]   Dict;//sure ok.
alias string[string][] dict;//Error

void main()
{
 Dict   = [[Cow:moo ],[Duck:quack]];//cool
 Dict  ~=  [Dog:woof]   //No  
prob.
assert(Dict==[[Cow:moo],[Duck:quack],[Dog:woof]]);//looks  
legit

 dict temp  = [[Cow:moo ],[Duck:quack]];//Error
 string[string][] temp2 = [[Cow:moo ],[Duck:quack]];//Error


 //And My favorite one of all:
 auto temp2 = [[Cow:moo],[Duck:quack]];  //Error
}

I've hit stuff like this before, and I've always assumed it was just  
karma for screwing with it.  I can't figure out why it does this.


These are definite bugs. Please file:

http://d.puremagic.com/issues/enter_bug.cgi




--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Stringy Weirdness

2012-08-18 Thread 1100110

But it *doesn't* work just fine without the alias.  =P

There are very specific things that *make* it work,
so I couldn't figure out if it was ever *supposed* to work.
Either the bug was the fact that it worked, or the bug was the fact that  
it didn't work.


immutable(char)[immutable(char)[]][] does not work at all.(*I* can't make  
it work)

alias currently (2.060) does not seem to work with AA at all.
auto currently does not work with AA.
array literals currently do not work with AA.

you cannot do string[string][] thing = [[t:f]];
but you *can* do string[string][] thing; thing = [[t:f]];//on the same  
line, no less...


you cannot do alias string[string][string] Dict;
and there doesn't seem to be a workaround.

you cannot do auto Dict = [[a:b]];
and there doesn't seem to be a workaround.


D really is amazing in that these features exist.
Work out all of the minor bugs and work on Documentation a little and we  
are in

why the (insert explitive here) *aren't* you using D? territory.

I do however find it unacceptable that a major language feature(AA) does  
not play nice

with other language features(auto, alias, array literals).

I think that this bug (8557, or 5448 if they are too similar) should be  
upgraded in severity.

There is even a patch for 5448 that (seems to have) languished.

We should either fix AA so that it works properly, drop it completely,  
or(less acceptable IMO)

add a huge (See BUG 8557, 5448) to the top of http://dlang.org/hash-map
(But that's just my opinion)

What do you think?

On Sat, 18 Aug 2012 03:59:44 -0500, Era Scarecrow rtcv...@yahoo.com  
wrote:



On Saturday, 18 August 2012 at 07:54:18 UTC, 1100110 wrote:

Is it supposed to do that or not?  that's what I can't decide...  =P

It doesn't seem to like templates either.  A tls variable, Tuple, or a  
Variant seems to be the only way that

string[string][] works.  It wants a double?  a number anyways.


  Not it's not suppose to do that. An alias is just short hand for the  
longer version. If you can use it properly without the alias (but not  
with) than you have your answer. Fully expanded it's hard to read:P


  immutable(char)[immutable(char)[]][]

  It's like optimizations, they are added that change your code to be  
smaller, faster, inlined, using hardware tricks; But the usage and  
behavior of the code remains unchanged.



--
Using Opera's revolutionary email client: http://www.opera.com/mail/
ME: Opera, you ain't 'revolutionary'. That's like Apple claiming to be  
'innovative'.

Geez...


Re: Raw socket using data transfer

2012-08-18 Thread 1100110
On Wed, 01 Aug 2012 05:36:07 -0500, Regan Heath re...@netmail.co.nz  
wrote:


On Wed, 01 Aug 2012 11:00:54 +0100, Gangadhar gangadhar@gmail.com  
wrote:


By using raw s ocket programing data transfer from client to server  
please help me about this,any one have source code send me .


The phobos source contains socket code you can inspect .. perhaps not  
RAW sockets but I suspect you mean low-level STREAM or UDP and not  
actually RAW sockets (correct me if I'm wrong).  Otherwise, there is  
always google.  You do sockets programming in D, exactly as you would in  
C/C++ all you need is a .d file describing the C socket API (structures,  
and function signatures) and then you compile and link to ws2_32.lib (on  
windows).


R



Check out vibe.
http://vibed.org/

They have a raw tcp class you can use.
http://vibed.org/api/vibe.core.tcp#TcpConnection
--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Stringy Weirdness

2012-08-17 Thread 1100110

I haven't been quite able to figure this one out.

string[string][]   Dict;//sure ok.
alias string[string][] dict;//Error

void main()
{
Dict   = [[Cow:moo 
],[Duck:quack]];//cool
Dict  ~=  [Dog:woof]   
//No prob.
assert(Dict==[[Cow:moo],[Duck:quack],[Dog:woof]]);//looks 
legit
dict temp  = [[Cow:moo 
],[Duck:quack]];//Error
string[string][] temp2 = [[Cow:moo 
],[Duck:quack]];//Error



//And My favorite one of all:
auto temp2 = [[Cow:moo],[Duck:quack]];  //Error
}

I've hit stuff like this before, and I've always assumed it was 
just karma for screwing with it.  I can't figure out why it does 
this.


Re: char ***argc problems.

2012-08-12 Thread 1100110

Would this help?
https://github.com/1100110/OpenMPI

On Sun, 12 Aug 2012 15:30:57 -0500, Andrew andrew.sp...@gmail.com wrote:


I'm attempting to create a wrapper for MPI, however, MPI_Init
wants to read the arguments for main():

MPI_Init(int *argv, char ***argc);

How do I get this last level of pointer reference?

So far, I have:

void main (string[] args)
{
  auto argarr = new char*[args.length];
  foreach(i, a; args)
  argarr[i] = (a.dup ~ '\0').ptr;

  int argc = to!(int)(argarr.length);
  MPI_Init(argc, argarr.ptr);
}

Any ideas?

-Andrew



--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: char ***argc problems.

2012-08-12 Thread 1100110
Also the Elementary repo has a wrapper for main() from E17, might be  
useful.


On Sun, 12 Aug 2012 15:54:45 -0500, 1100110 10equa...@gmail.com wrote:


Would this help?
https://github.com/1100110/OpenMPI

On Sun, 12 Aug 2012 15:30:57 -0500, Andrew andrew.sp...@gmail.com  
wrote:



I'm attempting to create a wrapper for MPI, however, MPI_Init
wants to read the arguments for main():

MPI_Init(int *argv, char ***argc);

How do I get this last level of pointer reference?

So far, I have:

void main (string[] args)
{
  auto argarr = new char*[args.length];
  foreach(i, a; args)
  argarr[i] = (a.dup ~ '\0').ptr;

  int argc = to!(int)(argarr.length);
  MPI_Init(argc, argarr.ptr);
}

Any ideas?

-Andrew






--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: char ***argc problems.

2012-08-12 Thread 1100110

Would this be useful?
https://github.com/1100110/OpenMPI

On Sunday, 12 August 2012 at 20:52:03 UTC, Simen Kjaeraas wrote:
On Sun, 12 Aug 2012 22:30:57 +0200, Andrew 
andrew.sp...@gmail.com wrote:



I'm attempting to create a wrapper for MPI, however, MPI_Init
wants to read the arguments for main():

MPI_Init(int *argv, char ***argc);

How do I get this last level of pointer reference?

So far, I have:

void main (string[] args)
{
 auto argarr = new char*[args.length];
 foreach(i, a; args)
 argarr[i] = (a.dup ~ '\0').ptr;

 int argc = to!(int)(argarr.length);
 MPI_Init(argc, argarr.ptr);
}

Any ideas?



// Array of pointers to command line parameters.
char*[] argv = args.map!((a)=(a.dup~'\0').ptr).array;
// Address of first element of that array.
char** argvp = argv[0];
// And finally, address of the pointer to that first 
element.

char*** argvpp = argvp;

Now, the interesting part is reconstructing the string[] from
the potentially modified argvpp...





Re: char ***argc problems.

2012-08-12 Thread 1100110

(sorry for spam...)

On Sunday, 12 August 2012 at 21:04:55 UTC, 1100110 wrote:

Would this be useful?
https://github.com/1100110/OpenMPI

On Sunday, 12 August 2012 at 20:52:03 UTC, Simen Kjaeraas wrote:
On Sun, 12 Aug 2012 22:30:57 +0200, Andrew 
andrew.sp...@gmail.com wrote:



I'm attempting to create a wrapper for MPI, however, MPI_Init
wants to read the arguments for main():

MPI_Init(int *argv, char ***argc);

How do I get this last level of pointer reference?

So far, I have:

void main (string[] args)
{
auto argarr = new char*[args.length];
foreach(i, a; args)
argarr[i] = (a.dup ~ '\0').ptr;

int argc = to!(int)(argarr.length);
MPI_Init(argc, argarr.ptr);
}

Any ideas?



   // Array of pointers to command line parameters.
   char*[] argv = args.map!((a)=(a.dup~'\0').ptr).array;
   // Address of first element of that array.
   char** argvp = argv[0];
   // And finally, address of the pointer to that first 
element.

   char*** argvpp = argvp;

Now, the interesting part is reconstructing the string[] from
the potentially modified argvpp...





Re: char ***argc problems.

2012-08-12 Thread 1100110
Let me know if you see something weird, I haven't tried building that in a  
long time.


Re: LDC -noruntime

2012-07-06 Thread 1100110

I swear you guys read my mind sometimes...  It's creepy.

I just had this very issue, doing the exact same thing, about an hour ago.

Have you tried with -nodefaultlib -noruntime ?  Cause that's what works  
for me...


I just got *something* to compile with no runtime or std.
Whether or not it actually does anything remains to be seen.


On Fri, 06 Jul 2012 01:53:10 -0500, BLM768 blm...@gmail.com wrote:

I've been trying to write an OS kernel in D, and I'm having issues with  
the runtime. I'm trying to use LDC's -noruntime option, which is  
_supposed_ to prevent any runtime calls from being generated, but the  
linker keeps complaining about unresolved references to _d_assert_msg  
and other runtime functions. It seems that LDC is ignoring the switch  
and is generating runtime references anyway. Is there some other way to  
force it to stop trying to pull in the runtime? I'd rather not have to  
create/link a custom runtime at this point; I don't even have a memory  
allocator written, so I really don't want to mess with a runtime yet.



--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: LDC -noruntime

2012-07-06 Thread 1100110

Wow, I haven't had that much trouble.  But I've tried to keep everything
at my level.  It's about half xomb. =P

I salute you for your bravery.

I had planned to stay far, far away from as much of that as I could.



On Fri, 06 Jul 2012 22:45:53 -0500, BLM768 blm...@gmail.com wrote:


On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:

I swear you guys read my mind sometimes...  It's creepy.

I just had this very issue, doing the exact same thing, about an hour  
ago.


Have you tried with -nodefaultlib -noruntime ?  Cause that's what works  
for me...


I just got *something* to compile with no runtime or std.
Whether or not it actually does anything remains to be seen.




No luck; it still references the runtime.
I've been stubbing out the runtime; it seems to be about done except for  
references to some functions I can't find. The symbols are __moddi3 and  
__divdi3; I assume they're C math library functions, as they're  
generated from code that uses div/mod operations. It also seems to be  
unable to properly find Object.toString() after I changed it to be  
nothrow, which I needed to do because I'm stubbing out the exception  
handling routines; it seems to have changed the mangling. It's a bit of  
a mess in there; I'm glad I don't always have to hack up the runtime :).






--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: Writing .di files

2012-06-23 Thread 1100110
On Fri, 22 Jun 2012 13:13:52 -0500, Minas Mina  
minas_mina1...@hotmail.co.uk wrote:


I'm sorry, what I meant was how to interface to C code. Sorry for  
writing it in a bad way.


Do I just declare the C code as extern and then link together with the C  
.lib/.o/.so file? (I'm in Ubuntu)


What about the stuff that is in header files?


Take a look at the Deimos Repos on Github.   
https://github.com/D-Programming-Deimos


Take a look at ncurses there.  There are two folders, C and deimos.
It needs to be cleaned up, but you'll notice that the .d files are really  
nothing more than a direct

translation of the C header files.

Include the translated header and link with the C library.

If you have a specific library that you want to interface to, it's pretty  
easy once you realize what needs to be done.


Global variables in C are truly global, but in D they are Thread Local.
So certain variables will need to be immutable, shared, __gshared,  
whatever.


Everything will need to be wrapped with 'extern (C)'

The biggest issues your likely to face are the Thread Local Storage issues  
and

the preprocessor directives.

dmd -vtls will print out the problem vars...

You can translate partial header files, just make sure you get all the  
relevant bits.


If you wanna play around, then add this to a file and compile it.

import std.string: toStringz;

extern (C) int system(in char* command);

auto newTerm(S:string)(S command)
{   return system(command.toStringz);   }

Yeah, I hate dealing with toStringz directly

Unlike the functions in std.process, this one will allow interactive  
programs to be run from inside a D file.

try newTerm(vim ~/.vimrc);

Yeah i just killed my terminal making sure std.process wouldn't work with  
that.






--
Using Opera's revolutionary email client: http://www.opera.com/mail/


GtkD compile failed. shift by 32

2012-06-10 Thread 1100110

http://svn.dsource.org/projects/gtkd/branches/070125merge/gtkD/src/gdk/Color.d


uint getValue()
{
return (gdkColor.red 32) | (gdkColor.green  16) | (gdkColor.blue);
}


Just browsing through the source it looks like gtkColor.red is a ushort.
I get this error.

dmd -O -m64 -Isrc -c src/gdk/Pixbuf.d -ofsrc/gdk/Pixbuf.o
src/gdk/Color.d(231): Error: shift by 32 is outside the range 0..31
make: *** [src/gdk/Color.o] Error 1
make: *** Waiting for unfinished jobs
== ERROR: A failure occurred in build().

I get that exact same message no matter which compiler I use.

Does any

--
Using Opera's rev...Shutit Opera.
Firefox is catching up. Apparently their machines ran
out of RAM too.


Re: using deimos.portaudio

2012-05-18 Thread 1100110
On Fri, 18 May 2012 21:31:57 -0500, Samuele Carcagno  
sam.carca...@gmail.com wrote:



Pa_OpenStream


Does the result of calling Pa_GetVersionText() closely match the version  
of the library installed on your computer?


I use Debian as well, and it's not exactly known for speedy updates...
If your version is too old you'll probably have to backport the changes or  
compile a newer version.


(both are relatively easy.)

Did you call the initialization before trying this?


--
Using Opera's revolutionary email client: http://www.opera.com/mail/