Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.3 KiB

  1. #ifndef __glumysetjmp_h_
  2. #define __glumysetjmp_h_
  3. /**************************************************************************
  4. * *
  5. * Copyright (C) 1992, Silicon Graphics, Inc. *
  6. * *
  7. * These coded instructions, statements, and computer programs contain *
  8. * unpublished proprietary information of Silicon Graphics, Inc., and *
  9. * are protected by Federal copyright law. They may not be disclosed *
  10. * to third parties or copied or duplicated in any form, in whole or *
  11. * in part, without the prior written consent of Silicon Graphics, Inc. *
  12. * *
  13. **************************************************************************/
  14. /*
  15. * mysetjmp.h - $Revision: 1.3 $
  16. */
  17. #ifdef STANDALONE
  18. struct JumpBuffer;
  19. #ifdef NT
  20. extern "C" JumpBuffer * GLOS_CCALL newJumpbuffer( void );
  21. extern "C" void GLOS_CCALL deleteJumpbuffer(JumpBuffer *);
  22. extern "C" void GLOS_CCALL mylongjmp( JumpBuffer *, int );
  23. extern "C" int GLOS_CCALL mysetjmp( JumpBuffer * );
  24. #else
  25. extern "C" JumpBuffer *newJumpbuffer( void );
  26. extern "C" void deleteJumpbuffer(JumpBuffer *);
  27. extern "C" void mylongjmp( JumpBuffer *, int );
  28. extern "C" int mysetjmp( JumpBuffer * );
  29. #endif // NT
  30. #endif
  31. extern "C" DWORD gluMemoryAllocationFailed;
  32. #ifdef GLBUILD
  33. #define setjmp gl_setjmp
  34. #define longjmp gl_longjmp
  35. #endif
  36. #if LIBRARYBUILD | GLBUILD | defined(NT)
  37. #include <setjmp.h>
  38. #ifndef NT
  39. #include <stdlib.h>
  40. #endif
  41. struct JumpBuffer {
  42. jmp_buf buf;
  43. };
  44. #ifdef NT
  45. inline JumpBuffer * GLOS_CCALL
  46. #else
  47. inline JumpBuffer *
  48. #endif
  49. newJumpbuffer( void )
  50. {
  51. #ifdef NT
  52. JumpBuffer *tmp;
  53. tmp = (JumpBuffer *) LocalAlloc(LMEM_FIXED, sizeof(JumpBuffer));
  54. if (tmp == NULL) gluMemoryAllocationFailed++;
  55. return tmp;
  56. #else
  57. return (JumpBuffer *) malloc( sizeof( JumpBuffer ) );
  58. #endif
  59. }
  60. #ifdef NT
  61. inline void GLOS_CCALL
  62. #else
  63. inline void
  64. #endif
  65. deleteJumpbuffer(JumpBuffer *jb)
  66. {
  67. #ifdef NT
  68. LocalFree( (HLOCAL) jb);
  69. #else
  70. free( (void *) jb);
  71. #endif
  72. }
  73. #ifdef NT
  74. inline void GLOS_CCALL
  75. #else
  76. inline void
  77. #endif
  78. mylongjmp( JumpBuffer *j, int code )
  79. {
  80. ::longjmp( j->buf, code );
  81. }
  82. #ifdef NT
  83. inline int GLOS_CCALL
  84. #else
  85. inline int
  86. #endif
  87. mysetjmp( JumpBuffer *j )
  88. {
  89. return ::setjmp( j->buf );
  90. }
  91. #endif
  92. #endif /* __glumysetjmp_h_ */