From patchwork Sat Feb 5 21:44:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Blomqvist X-Patchwork-Id: 82020 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 47AAEB7125 for ; Sun, 6 Feb 2011 08:45:02 +1100 (EST) Received: (qmail 3263 invoked by alias); 5 Feb 2011 21:45:00 -0000 Received: (qmail 3245 invoked by uid 22791); 5 Feb 2011 21:44:59 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_BG X-Spam-Check-By: sourceware.org Received: from mail-iw0-f175.google.com (HELO mail-iw0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Feb 2011 21:44:52 +0000 Received: by iwn8 with SMTP id 8so3521163iwn.20 for ; Sat, 05 Feb 2011 13:44:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.145.68 with SMTP id c4mr15144102ibv.47.1296942288834; Sat, 05 Feb 2011 13:44:48 -0800 (PST) Received: by 10.231.160.68 with HTTP; Sat, 5 Feb 2011 13:44:48 -0800 (PST) Date: Sat, 5 Feb 2011 23:44:48 +0200 Message-ID: Subject: [Patch, fortran] Document libgfortran thread-safety From: Janne Blomqvist To: Fortran List , GCC Patches 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 Hi, continuing my monologue at http://gcc.gnu.org/ml/fortran/2011-02/msg00028.html , here's a patch that documents the thread-safety of libgfortran. Tested with make pdf, Ok for trunk? 2011-02-05 Janne Blomqvist * gfortran.texi (Thread-safety): New section. * intrinsic.texi (EXECUTE_COMMAND_LINE): Mention thread-safety. (GETENV): Likewise. (GET_ENVIRONMENT_VARIABLE): Likewise. (SYSTEM): Likewise. diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index a34d82e..54f2457 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1157,6 +1157,36 @@ representation of @code{LOGICAL} variables in GNU Fortran is identical to C99 _Bool, except for a possible difference in storage size depending on the kind. + +@node Thread-safety of the runtime library +@section Thread-safety of the runtime library +@cindex thread-safety, threads + +GNU Fortran can be used in programs with multiple threads, e.g. by +using OpenMP, by calling OS thread handling functions via the +@code{ISO_C_BINDING} facility, or by GNU Fortran compiled library code +being called from a multi-threaded program. + +The GNU Fortran runtime library, (@var{libgfortran}), supports being +called concurrently from multiple threads with the following +exceptions. + +During library initialization, the C @code{getenv()} function is used, +which need not be thread-safe. Similarly, the @code{getenv()} +function is used to implement the @code{GET_ENVIRONMENT_VARIABLE} and +@code{GETENV} intrinsics. It is the responsibility of the user to +ensure that the environment is not being updated concurrently when any +of these actions are taking place. + +The @code{EXECUTE_COMMAND_LINE} and @code{SYSTEM} intrinsics are +implemented with the @code{system()} function, which need not be +thread-safe. It is the responsibility of the user to ensure that +@code{system()} is not called concurrently. + +Finally, for platforms not supporting thread-safe @code{POSIX} +functions, further functionality might not be thread-safe. For +details, please consult the documentation for your operating system. + @c --------------------------------------------------------------------- @c Extensions @c --------------------------------------------------------------------- diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index f0287f6..ea5528f 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -4162,6 +4162,9 @@ the command, as returned by @code{system}. @code{CMDSTAT} is set to zero if the command line was executed (whatever its exit status was). @code{CMDMSG} is assigned an error message if an error has occurred. +Note that the @code{system()} call need not be thread-safe. It is the +responsibility of the user to ensure that @code{system()} is not +called concurrently. @item @emph{Standard}: Fortran 2008 and later @@ -5452,11 +5455,15 @@ END PROGRAM @item @emph{Description}: Get the @var{VALUE} of the environmental variable @var{NAME}. -This intrinsic routine is provided for backwards compatibility with -GNU Fortran 77. In new code, programmers should consider the use of +This intrinsic routine is provided for backwards compatibility with +GNU Fortran 77. In new code, programmers should consider the use of the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran 2003 standard. +Note that @code{GETENV} need not be thread-safe. It is the +responsibility of the user to ensure that the environment is not being +updated concurrently with a call to the @code{GETENV} intrinsic. + @item @emph{Standard}: GNU extension @@ -5501,6 +5508,11 @@ END PROGRAM @item @emph{Description}: Get the @var{VALUE} of the environmental variable @var{NAME}. +Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It +is the responsibility of the user to ensure that the environment is +not being updated concurrently with a call to the +@code{GET_ENVIRONMENT_VARIABLE} intrinsic. + @item @emph{Standard}: Fortran 2003 and later @@ -11779,6 +11791,10 @@ and environment-dependent. This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit. +Note that the @code{system()} call need not be thread-safe. It is the +responsibility of the user to ensure that @code{system()} is not +called concurrently. + @item @emph{Standard}: GNU extension