1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/glpenv02.c Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,73 @@
1.4 +/* glpenv02.c (thread local storage) */
1.5 +
1.6 +/***********************************************************************
1.7 +* This code is part of GLPK (GNU Linear Programming Kit).
1.8 +*
1.9 +* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
1.10 +* 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
1.11 +* Moscow Aviation Institute, Moscow, Russia. All rights reserved.
1.12 +* E-mail: <mao@gnu.org>.
1.13 +*
1.14 +* GLPK is free software: you can redistribute it and/or modify it
1.15 +* under the terms of the GNU General Public License as published by
1.16 +* the Free Software Foundation, either version 3 of the License, or
1.17 +* (at your option) any later version.
1.18 +*
1.19 +* GLPK is distributed in the hope that it will be useful, but WITHOUT
1.20 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.21 +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1.22 +* License for more details.
1.23 +*
1.24 +* You should have received a copy of the GNU General Public License
1.25 +* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
1.26 +***********************************************************************/
1.27 +
1.28 +#include "glpenv.h"
1.29 +
1.30 +static void *tls = NULL;
1.31 +/* in a re-entrant version of the package this variable must be placed
1.32 + in the Thread Local Storage (TLS) */
1.33 +
1.34 +/***********************************************************************
1.35 +* NAME
1.36 +*
1.37 +* tls_set_ptr - store global pointer in TLS
1.38 +*
1.39 +* SYNOPSIS
1.40 +*
1.41 +* #include "glpenv.h"
1.42 +* void tls_set_ptr(void *ptr);
1.43 +*
1.44 +* DESCRIPTION
1.45 +*
1.46 +* The routine tls_set_ptr stores a pointer specified by the parameter
1.47 +* ptr in the Thread Local Storage (TLS). */
1.48 +
1.49 +void tls_set_ptr(void *ptr)
1.50 +{ tls = ptr;
1.51 + return;
1.52 +}
1.53 +
1.54 +/***********************************************************************
1.55 +* NAME
1.56 +*
1.57 +* tls_get_ptr - retrieve global pointer from TLS
1.58 +*
1.59 +* SYNOPSIS
1.60 +*
1.61 +* #include "glpenv.h"
1.62 +* void *tls_get_ptr(void);
1.63 +*
1.64 +* RETURNS
1.65 +*
1.66 +* The routine tls_get_ptr returns a pointer previously stored by the
1.67 +* routine tls_set_ptr. If the latter has not been called yet, NULL is
1.68 +* returned. */
1.69 +
1.70 +void *tls_get_ptr(void)
1.71 +{ void *ptr;
1.72 + ptr = tls;
1.73 + return ptr;
1.74 +}
1.75 +
1.76 +/* eof */