Date: Sun, 2 Mar 2014 14:50:53 -0500 From: Julio Merino <jmmv@freebsd.org> To: ghostmansd@gmail.com Cc: hackers@freebsd.org Subject: Re: GSoC proposal: Quirinus C library (qc) Message-ID: <CAFY7cWD-dPBvMY4UFTB8MnAggt8Zr_oUijuax-WVYkfPBTD0=g@mail.gmail.com> In-Reply-To: <CAMqzjevCoS2qA7jmpPmOXpfzrsD1LzNMJbC8sw-Op-KB-UMhXQ@mail.gmail.com> References: <CAMqzjevCoS2qA7jmpPmOXpfzrsD1LzNMJbC8sw-Op-KB-UMhXQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello Dmitry, As others have mentioned, having such a BSD-licensed library would be a nice thing, but it's also a huge undertake. I guess that if you scope the project properly, you'd come out of GSoC with just a tiny piece of it working. But that has already been discussed. The reason I'm replying is because of the one comment below: On Tue, Feb 25, 2014 at 3:24 AM, Dmitry Selyutin <ghostman.sd@gmail.com> wrote: > > 2. Common and universal error type, qc_error. Such errors can be generated > from errno values as well as from Windows API errors. > Almost all functions from qc library except for the three common functions > (constructor, destructor, replicator) return qc_error code and set specific > qc_errno variable to this code. > It is now possible to write such constructions: > if (qc_bytes_import_str(bytes_instance, "Hello, world!")) > qc_errormsg(qc_errno, "error check"); > Global variable qc_errno is implemented in terms of multithreading > applications, it is unique for every running thread. For error handling, I'm quite happy with what I did in ATF/Kyua. Basically, indicating "no error" brings no more overhead than returning and checking a NULL pointer, whereas indicating "error" can provide arbitrary amounts of information in dynamically-allocated structures. There is no global state (i.e. no "errno" style variables). The base library has support to pass around "libc" errors, usage errors, generic errors and OOM errors. The latter are interesting because no memory allocation should take place when reporting an OOM condition. Lastly, client code can define its own error objects if so wishes to pass around other structured data. The code, BSD-licensed, is here: https://github.com/jmmv/kyua/blob/master/kyua-testers/error_fwd.h https://github.com/jmmv/kyua/blob/master/kyua-testers/error.h https://github.com/jmmv/kyua/blob/master/kyua-testers/error.c
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFY7cWD-dPBvMY4UFTB8MnAggt8Zr_oUijuax-WVYkfPBTD0=g>