From patchwork Fri Sep 24 08:04:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 65630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C6232B70F9 for ; Fri, 24 Sep 2010 18:04:54 +1000 (EST) Received: (qmail 18409 invoked by alias); 24 Sep 2010 08:04:52 -0000 Received: (qmail 18396 invoked by uid 22791); 24 Sep 2010 08:04:50 -0000 X-SWARE-Spam-Status: No, hits=0.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_PSBL, SARE_SUB_ENC_UTF8, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Sep 2010 08:04:46 +0000 Received: from eggs.gnu.org ([140.186.70.92]:41941) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Oz3Gt-0003bE-Q1 for gcc-patches@gnu.org; Fri, 24 Sep 2010 04:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oz3Gs-0007Wq-BU for gcc-patches@gnu.org; Fri, 24 Sep 2010 04:04:43 -0400 Received: from smtp191.iad.emailsrvr.com ([207.97.245.191]:38729) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oz3Gs-0007WS-9I for gcc-patches@gnu.org; Fri, 24 Sep 2010 04:04:42 -0400 Received: from relay29.relay.iad.mlsrvr.com (localhost [127.0.0.1]) by relay29.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id C1A581B412F; Fri, 24 Sep 2010 04:04:39 -0400 (EDT) Received: from dynamic3.wm-web.iad.mlsrvr.com (dynamic3.wm-web.iad.mlsrvr.com [192.168.2.152]) by relay29.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id BBDFC1B4054; Fri, 24 Sep 2010 04:04:39 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic3.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id AAB60332006E; Fri, 24 Sep 2010 04:04:39 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Fri, 24 Sep 2010 10:04:39 +0200 (CEST) Date: Fri, 24 Sep 2010 10:04:39 +0200 (CEST) Subject: =?UTF-8?Q?Re:=20GNU=20Objective-C=20runtime=20support=20for=20@synchroni?= =?UTF-8?Q?zed()?= From: "Nicola Pero" To: "Andrew Pinski" Cc: gcc-patches@gnu.org MIME-Version: 1.0 X-Type: plain In-Reply-To: References: <1283633079.369513754@192.168.2.227> Message-ID: <1285315479.6973093@192.168.2.230> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Andrew (responding to an old email of yours that was stuck in my TODO list) > I forgot to mention this is PR 23680. And can you add a testcase or two? Yes, good idea - today I added a testcase for @synchronized(). This should help flagging up if changes in the compiler break something basic in @synchronized(). It won't test much of the runtime implementation of @synchronized(); testing that properly would require starting up lots of different threads etc. I do have such tests which I used while implementing the runtime support, but it is not trivial to integrate them into the testsuite (to start with, I don't think we have anything to run ObjC tests in multithreading [by linking the appropriate thread library] - all tests run in single-thread mode at the moment [since they don't link any threading library]). And serious threading tests are very expensive to run as you have to have lots of threads doing a lot to try catch any synchronization issues. :-( What we have should be enough for now. :-) Thanks Index: ChangeLog =================================================================== --- ChangeLog (revision 164584) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2010-09-24 Nicola Pero + + * objc.dg/sync-2.m: New test. + * obj-c++.dg/sync-2.mm: New test. + 2010-09-24 Tobias Burnus PR fortran/40571 Index: objc.dg/sync-2.m =================================================================== --- objc.dg/sync-2.m (revision 0) +++ objc.dg/sync-2.m (revision 0) @@ -0,0 +1,35 @@ +/* Make sure that @synchronized parses and a very basic test runs. */ +/* { dg-options "-fobjc-exceptions -fgnu-runtime" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +int main (void) +{ + Object *a = [Object new]; + Object *b = [Object new]; + Object *c = [Object new]; + + /* This single-threaded test just checks that @synchronized() uses a + recursive mutex, and that the runtime at least doesn't crash + immediately upon finding it. + */ + @synchronized (a) + { + @synchronized (a) + { + @synchronized (b) + { + @synchronized (b) + { + @synchronized (c) + { + @synchronized (c) + { + return 0; + } + } + } + } + } + } +} Index: obj-c++.dg/sync-2.mm =================================================================== --- obj-c++.dg/sync-2.mm (revision 0) +++ obj-c++.dg/sync-2.mm (revision 0) @@ -0,0 +1,35 @@ +/* Make sure that @synchronized parses and a very basic test runs. */ +/* { dg-options "-fobjc-exceptions -fgnu-runtime" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +int main (void) +{ + Object *a = [Object new]; + Object *b = [Object new]; + Object *c = [Object new]; + + /* This single-threaded test just checks that @synchronized() uses a + recursive mutex, and that the runtime at least doesn't crash + immediately upon finding it. + */ + @synchronized (a) + { + @synchronized (a) + { + @synchronized (b) + { + @synchronized (b) + { + @synchronized (c) + { + @synchronized (c) + { + return 0; + } + } + } + } + } + }