From owner-svn-src-all@FreeBSD.ORG Sun Jun 30 19:44:57 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5D895108; Sun, 30 Jun 2013 19:44:57 +0000 (UTC) (envelope-from edschouten@gmail.com) Received: from mail-vb0-x235.google.com (mail-vb0-x235.google.com [IPv6:2607:f8b0:400c:c02::235]) by mx1.freebsd.org (Postfix) with ESMTP id F133B19A9; Sun, 30 Jun 2013 19:44:56 +0000 (UTC) Received: by mail-vb0-f53.google.com with SMTP id p12so2983982vbe.26 for ; Sun, 30 Jun 2013 12:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=c9JNL5xkBPFoRQhuWpJU7HDbh/mOpMMZ1+jWaV4NG00=; b=ylSn3HvMpsQHBbIxOWanDLtQ6LKjuCICQ7YyEJMXIpApte+7COCP8FM9yDZ6/elsV/ FYs7V2YY81FB4TN0khdGaG0nF5Ez0mHf1l3uehpZvzLgjgqilhb/2FEtfRl9x0lRPTFF Owr9W6otqM4ZAthumNS04yFAu2dyzZIEr+RVfP/JWWE4DlWJu00A36owpng5uoQPqCoN xFIF1SClH5GoV+6T+e/jnPUIF/Vg1RhNoWU6tiJgkkz7xjpHnveWg2WOMQO2hmsykupj Y6PV9NKTWzTFciMgkN9bQFbZyAGb/xYi2+QHGFcZX0hzAaMnXOH0lEhNIosIq9u7RbNI MpEQ== MIME-Version: 1.0 X-Received: by 10.52.120.77 with SMTP id la13mr7207261vdb.23.1372621496475; Sun, 30 Jun 2013 12:44:56 -0700 (PDT) Sender: edschouten@gmail.com Received: by 10.220.107.139 with HTTP; Sun, 30 Jun 2013 12:44:56 -0700 (PDT) In-Reply-To: <51D07C10.2000509@coosemans.org> References: <201306300854.r5U8sfYS018720@svn.freebsd.org> <51D07C10.2000509@coosemans.org> Date: Sun, 30 Jun 2013 21:44:56 +0200 X-Google-Sender-Auth: wKvPpTNjfVvfVGgZtDYc7X2BnS8 Message-ID: Subject: Re: svn commit: r252411 - head/sys/sys From: Ed Schouten To: Tijl Coosemans Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 19:44:57 -0000 Hi Tijl, 2013/6/30 Tijl Coosemans : > I don't think you can use static inline. Standard library functions need > to have external linkage, which means you have to implement them in libc. First of all, I could be mistaken, so please correct me if I say something wrong here. If my memory serves me right, this requirement is part of POSIX -- not ISO C. As this is interface is not yet part of any version of POSIX and at least I am not in the possession of a draft of POSIX that specified these functions, I think it would be unwise to add this to the C library. I think there is nothing that would forbid us to use static inline functions. As C11 merely names these things "functions", I think using a static inline function would currently be the wisest thing to do. To my knowledge the current version of the code at least complies with the standards at hand. > I think you can just use unsigned char. Only the test-and-set and clear > operations need to be atomic. Anything else (like copy-assignment) > doesn't have to be atomic. Both clang and gcc have __atomic_test_and_set > and __atomic_clear built-ins. Ah, nice. I was unaware of the existence of these functions. I'll see if I can switch our header to use that instead. Still, I think it's a bit weird that the API provided by both Clang and GCC provides such a poor abstraction. For example, if it weren't for our implementation of Restartable Atomic Sequences, even unsigned char would not have been a lockless type on ARMv5. -- Ed Schouten