Re: [kernel patch] fcntl(...) to close many descriptors

2001-01-29 Thread Bakul Shah
> >If you can get to old CACMs see `Minimal Perfect Hash Functions Made Simple' > >by Richard J. Cichelli, Comm. of ACM, Jan 1980. AFAIK gperf uses some > >variation of that algorithm and may have some details. A minimal perfect hash > >function is only worth it (IMHO) when the set of input keys

Re: [kernel patch] fcntl(...) to close many descriptors

2001-01-29 Thread Bakul Shah
This caught my eye: > Besides, there is no such thing as a > perfect hash ... at least not one that has a small enough index range > to be useful in a table lookup. If you can get to old CACMs see `Minimal Perfect Hash Functions Made Simple' by Richard J.

Re: syscall assembly

2000-12-16 Thread Bakul Shah
Marc sent me this: > > > > pushl %ebp > > > > movl %esp,%ebp > > > > subl $8,%esp > > > > > > > This might not be of interest to the rest of the mailing list > > > but what is the purpose of the subl instruction used before > > > calling functions? Is that where the return

Re: syscall assembly

2000-12-13 Thread Bakul Shah
> > #include > > > > int foo() { > > open("file", O_RDONLY); > > return 0; > > } > > int main() { > > int x; > > x = foo(); > > return 0; > > } > > > > results in: > > > > foo: > > pushl %ebp > > movl %esp,%ebp > > subl $8,%esp > > addl $-8,%esp > >

Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Bakul Shah
> why not just bind to the port and then spawn off some processes (like 20 > in his case) to do the accept(), once the accept() returns successfully just > take care of the request, close the connection and then goes back > to accept(). Simple, easy, and even scales pretty well. Since > it's fr

Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Bakul Shah
> What's the best approach for a simple web-server(never more the 10 clients) > ? Is it using pthread and a thread per connection . Or to make a > non-blocking single thread server. Can people show me some simple examples > of the 2 techniques ? > > And what's the pro's and con's for the 2 method

Re: X11/C++ question

1999-10-26 Thread Bakul Shah
Allow me add something to what the FAQ-Xt says. I find it more convenient to immediately call a non-static function as shown below (using a slightly modified example from the FAQ). class Icon { public: Icon(Widget*); private: static void static_callback(Icon*)

Re: Search a symbol in the source tree

1999-10-18 Thread Bakul Shah
A couple of useful packages can make this much quicker. mkid from ports/devel/id-utils builds a database of symbols given a source tree. Then you can use gid to grep for a symbol, lid to get a list of files that havea symbol etc. mkid knows about c, c++ and may be some other languages. If you w

Re: Bug in dd seeking beyond 2G

1999-09-15 Thread Bakul Shah
> date: 1999/06/19 19:49:32; author: green; state: Exp; lines: +25 -21 > Miscellaneous dd(1) changes: mainly fixing variable types (size_t, > ssize_t, off_t, int, u_int64_t, etc.). dd(1) should now work properly > with REALLY big amounts of data. > > Should be a -stable candidate by now (3 mont

Re: Bug in dd seeking beyond 2G

1999-09-15 Thread Bakul Shah
> date: 1999/06/19 19:49:32; author: green; state: Exp; lines: +25 -21 > Miscellaneous dd(1) changes: mainly fixing variable types (size_t, > ssize_t, off_t, int, u_int64_t, etc.). dd(1) should now work properly > with REALLY big amounts of data. > > Should be a -stable candidate by now (3 mon

Bug in dd seeking beyond 2G

1999-09-15 Thread Bakul Shah
PR bin/6509 (submitted in May 1998) already has a patch to fix this but it was rejected because off_t was assumed by the bug fixer/submitter to be a quat (int64_t). I can't even get an IDE disk below 2G byte easily! And we are still years away from zettabyte disks. So I don't see the point of b

Bug in dd seeking beyond 2G

1999-09-15 Thread Bakul Shah
PR bin/6509 (submitted in May 1998) already has a patch to fix this but it was rejected because off_t was assumed by the bug fixer/submitter to be a quat (int64_t). I can't even get an IDE disk below 2G byte easily! And we are still years away from zettabyte disks. So I don't see the point of bl

Re: from number to power of two

1999-08-22 Thread Bakul Shah
The best I can come up with is this: /* kk+1 k * given n, return 2 such that 2> n >= 2 */ inline unsigned long n2power2(unsigned long n) { /* `smear' the highest set bit to the right */ n |= n>>1; n |= n>>2; n |= n>>4; n |= n>>8; n |= n>>

Re: from number to power of two

1999-08-22 Thread Bakul Shah
The best I can come up with is this: /* kk+1 k * given n, return 2 such that 2> n >= 2 */ inline unsigned long n2power2(unsigned long n) { /* `smear' the highest set bit to the right */ n |= n>>1; n |= n>>2; n |= n>>4; n |= n>>8; n |= n>

Re: OpenBSD's strlcpy(3) and strlcat(3)

1999-07-15 Thread Bakul Shah
Any use of str{,n}cat makes me gag. In the past I have used a composable function that may be of interest. Composable in the sense that the result can be immediately used as an arg to another call and it doesn't have the O(N^2) behavior of strcat. Such a function can be totally safe. Something

Re: OpenBSD's strlcpy(3) and strlcat(3)

1999-07-15 Thread Bakul Shah
Any use of str{,n}cat makes me gag. In the past I have used a composable function that may be of interest. Composable in the sense that the result can be immediately used as an arg to another call and it doesn't have the O(N^2) behavior of strcat. Such a function can be totally safe. Something

<    1   2