From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 2 19:51:21 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7C28ACB0 for ; Sun, 2 Mar 2014 19:51:21 +0000 (UTC) Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 379AD1293 for ; Sun, 2 Mar 2014 19:51:20 +0000 (UTC) Received: by mail-qc0-f171.google.com with SMTP id x13so1742989qcv.30 for ; Sun, 02 Mar 2014 11:51:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=NEueXTMhUMlMA/z2M1BKrSAfAXTHhbMt2NmGlNqEqe4=; b=j7mv4I94z96wbkzGEHU2B8OcLg/b1XRhdhAr4YB8/ny9S7FxEOODVeXpPPHbW3ZGcY uS9m3kWM2ikSoKDSdLBCnDrC/U3LoxqII2Qvzp/PLKpsVYPkxcGPkLWr1A07MjOKcUpD GvgHT9wUJrW/+zjIxVV62lJ2GyqWGpqeShPSB6zMED6dMwkJKgaj6N70dmz5u6UilQW1 D9kBtxeqOIZ8HTCizb/2eg237yTwPpOcc2+rglbKicjCwJVihfA6lIUVdcfNHoetllUw 8uegXcGaFIpCYe8VvDOrziTdUq7N885NyV+TfdfAJ/ED2XqKVl8Y7zG7cjZeHYFmpmgG J8yQ== X-Gm-Message-State: ALoCoQnCpOa+huRmSU2jZlOeHeBwaOOLBxuskSLBovsOMq0i2eQNuBHzT2lpPPQtQlaxvTKTPYaG X-Received: by 10.140.37.47 with SMTP id q44mr18153166qgq.57.1393789873548; Sun, 02 Mar 2014 11:51:13 -0800 (PST) MIME-Version: 1.0 Sender: jmmv@meroh.net Received: by 10.96.83.102 with HTTP; Sun, 2 Mar 2014 11:50:53 -0800 (PST) X-Originating-IP: [108.176.158.82] In-Reply-To: References: From: Julio Merino Date: Sun, 2 Mar 2014 14:50:53 -0500 X-Google-Sender-Auth: oBmdPah4QT-HXRpjm-tJYQtHAjo Message-ID: Subject: Re: GSoC proposal: Quirinus C library (qc) To: ghostmansd@gmail.com Content-Type: text/plain; charset=ISO-8859-1 Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Mar 2014 19:51:21 -0000 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 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