functions that do not sleep and recovery points

2012-07-21 Thread akaz
Hi, In Linux kernel programming, there are some parts that are not allowed to sleep (to be rescheduled). For example: interrupt handlers, softirqs and tasklets. Using functions that can sleep (for example: malloc, semaphores, regular mutexes - unlike spin_locks, etc.) is forbidden inside

Re: why is string not implicit convertable to const(char*) ?

2012-07-07 Thread akaz
Well, then we're going to have to agree to disagree on that one. While some design decisions may have made more sense at the time they were made or the ultimate pros and cons may not have been clear at the time, I think that zero- terminated strings are one of the design decisions which was tru

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread akaz
Won't some functions doing just what addRange() and removeRange() do solve that kind of problem (if necessary)? That means, forbidding the GC to scan some memory area for some time? Like their C++11 counterparts: void declare_reachable(void* p); // the region of memory starting at p

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread akaz
On Friday, 6 July 2012 at 21:10:56 UTC, Simon wrote: On 06/07/2012 16:39, Alex Rønne Petersen wrote: On 06-07-2012 16:07, Denis Shelomovskij wrote: 06.07.2012 17:43, akaz пишет: Never mind what D says, even in C/C++ just doing the p += 10 is invalid. Creating a pointer that points at

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread akaz
On Friday, 6 July 2012 at 15:39:40 UTC, Alex Rønne Petersen wrote: On 06-07-2012 16:07, Denis Shelomovskij wrote: 06.07.2012 17:43, akaz пишет: Hi, Reading about the C++11, I stumbled upon this: I'll just add: Handling this case is basically impossible to do sanely. You can't r

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread akaz
If you are interested in D read this first: http://dlang.org/garbage.html You can find there e.g.: > Do not add or subtract an offset to a pointer such that the result points outside of the bounds of the garbage collected object originally allocated. So `p+=10;` is already "undefined behavior

Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread akaz
Hi, Reading about the C++11, I stumbled upon this: http://www2.research.att.com/~bs/C++0xFAQ.html#gc-abi Specifically (quote): int* p = new int; p+=10; // ... collector may run here ... p-=10; *p = 10;// can we be sure that the int is still th

Re: std.stream.File help required (and classes)

2012-03-28 Thread akaz
(The data inside is not really what it should be, but that, at least, is a debugging problem, not a segfault one). Just to let you know that I did it. I was writing the good data (as double), but it was my verification test that assumed it to be int... Now I corrected it and it works! Any w

Re: std.stream.File help required (and classes)

2012-03-28 Thread akaz
I should also add that I allocated my structure with: (init) s.filedesc = cast(File*)GC.calloc(1,File.sizeof); (open) (*(s.filedesc)).open(*(cast(string*)arg),"w+b"); OMG! That solution works! Except that I was making a silly mistake and thought that GC.alloc() prototype is similar to C's c

Re: std.stream.File help required (and classes)

2012-03-28 Thread akaz
> I am a bit lost between pointers > (s->x or (*s).x) and values (s.x). For structures there are pointers, > for classes there are no pointers? Yes. Ali And migrating from std.stream.File (which was a class) to std.stdio.File (which is a structure) lost me completely. Why, in fact, std.stre

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
OK, I converted into using the std.stdio.File. Without success, the programs till crashes. However, in the meantime: A) why there is no parameter-less constructor for std.stdio.File? I would like to have into my "init" function: s.filedesc=new File() and, then, in my setter "open" method s.f

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
std.file is more about files and directories, not file contents. I've abandoned std.stream.File some time ago. I just use std.stdio.File partly because stdio, stdout, and stderr are of that type anyway. It works with ranges as well. should be re-named std.folder, then, or std.filesystem. havin

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
Thank you. But why do I lose access to my std.stream.File file? Somehow, the variable gets unallocated, thus the file is closed back? With pointers of C it used to be so simple... variable remained allocated untel the corresponding free(). I do not quite grasp this (a bit) awkward mix betwee

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
I should at that the "__gshared" attribute was added in distress, but changed nothing. With or without it, the program still crashes.

std.stream.File help required (and classes)

2012-03-27 Thread akaz
Hi all, I am trying to port some application based on a library called mediastreamer2, part of linphone software. The basic software component built on top of mediastreamer2 is called a "filter". Basically, it is a C structure with parameters and some methods (pointers to functions). Am