glpenv02.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* glpenv02.c (thread local storage) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  6. * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
  7. * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  8. * E-mail: <mao@gnu.org>.
  9. *
  10. * GLPK is free software: you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. * License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  22. ***********************************************************************/
  23. #include "glpenv.h"
  24. static void *tls = NULL;
  25. /* in a re-entrant version of the package this variable must be placed
  26. in the Thread Local Storage (TLS) */
  27. /***********************************************************************
  28. * NAME
  29. *
  30. * tls_set_ptr - store global pointer in TLS
  31. *
  32. * SYNOPSIS
  33. *
  34. * #include "glpenv.h"
  35. * void tls_set_ptr(void *ptr);
  36. *
  37. * DESCRIPTION
  38. *
  39. * The routine tls_set_ptr stores a pointer specified by the parameter
  40. * ptr in the Thread Local Storage (TLS). */
  41. void tls_set_ptr(void *ptr)
  42. { tls = ptr;
  43. return;
  44. }
  45. /***********************************************************************
  46. * NAME
  47. *
  48. * tls_get_ptr - retrieve global pointer from TLS
  49. *
  50. * SYNOPSIS
  51. *
  52. * #include "glpenv.h"
  53. * void *tls_get_ptr(void);
  54. *
  55. * RETURNS
  56. *
  57. * The routine tls_get_ptr returns a pointer previously stored by the
  58. * routine tls_set_ptr. If the latter has not been called yet, NULL is
  59. * returned. */
  60. void *tls_get_ptr(void)
  61. { void *ptr;
  62. ptr = tls;
  63. return ptr;
  64. }
  65. /* eof */