alpar@1: /* glpenv02.c (thread local storage) */ alpar@1: alpar@1: /*********************************************************************** alpar@1: * This code is part of GLPK (GNU Linear Programming Kit). alpar@1: * alpar@1: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@1: * 2009, 2010 Andrew Makhorin, Department for Applied Informatics, alpar@1: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@1: * E-mail: . alpar@1: * alpar@1: * GLPK is free software: you can redistribute it and/or modify it alpar@1: * under the terms of the GNU General Public License as published by alpar@1: * the Free Software Foundation, either version 3 of the License, or alpar@1: * (at your option) any later version. alpar@1: * alpar@1: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@1: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@1: * License for more details. alpar@1: * alpar@1: * You should have received a copy of the GNU General Public License alpar@1: * along with GLPK. If not, see . alpar@1: ***********************************************************************/ alpar@1: alpar@1: #include "glpenv.h" alpar@1: alpar@1: static void *tls = NULL; alpar@1: /* in a re-entrant version of the package this variable must be placed alpar@1: in the Thread Local Storage (TLS) */ alpar@1: alpar@1: /*********************************************************************** alpar@1: * NAME alpar@1: * alpar@1: * tls_set_ptr - store global pointer in TLS alpar@1: * alpar@1: * SYNOPSIS alpar@1: * alpar@1: * #include "glpenv.h" alpar@1: * void tls_set_ptr(void *ptr); alpar@1: * alpar@1: * DESCRIPTION alpar@1: * alpar@1: * The routine tls_set_ptr stores a pointer specified by the parameter alpar@1: * ptr in the Thread Local Storage (TLS). */ alpar@1: alpar@1: void tls_set_ptr(void *ptr) alpar@1: { tls = ptr; alpar@1: return; alpar@1: } alpar@1: alpar@1: /*********************************************************************** alpar@1: * NAME alpar@1: * alpar@1: * tls_get_ptr - retrieve global pointer from TLS alpar@1: * alpar@1: * SYNOPSIS alpar@1: * alpar@1: * #include "glpenv.h" alpar@1: * void *tls_get_ptr(void); alpar@1: * alpar@1: * RETURNS alpar@1: * alpar@1: * The routine tls_get_ptr returns a pointer previously stored by the alpar@1: * routine tls_set_ptr. If the latter has not been called yet, NULL is alpar@1: * returned. */ alpar@1: alpar@1: void *tls_get_ptr(void) alpar@1: { void *ptr; alpar@1: ptr = tls; alpar@1: return ptr; alpar@1: } alpar@1: alpar@1: /* eof */