thread.h
上传用户:ladybrid91
上传日期:2007-01-04
资源大小:287k
文件大小:3k
源码类别:

Web服务器

开发平台:

Unix_Linux

  1. /*
  2.  * THREAD.H - Solaris to POSIX Interface Layer for Threads.
  3.  *
  4.  * This code is public domain.  It may be freely distributed provided the
  5.  * Copyright notice is retained. This code is not supported in any way.
  6.  * Usage of the code is solely at the user's/programmer's discretion.
  7.  * Sun Microsystems makes no claim as to the reliabilty, correctness or
  8.  * suitability of this code. Sun Microsystems will not be held liable in
  9.  * any way as a result loss or damage arising from the use this code.
  10.  *
  11.  * Written by: Richard.Marejka@Canada.Sun.COM
  12.  * Copyright (c) 1994, by Sun Microsystems, Inc.
  13.  */
  14. #if !defined(THREAD_INCLUDED)
  15. #define THREAD_INCLUDED
  16. #pragma ident "@(#) thread.h.txt 1.1 94/10/06 Richard.Marejka@Canada.Sun.COM"
  17. /* Feature Test Macros */
  18. #define _POSIX_THREADS
  19. #if !defined(SPILT_MACROS)
  20. # define SPILT_MACROS 1 /* use macros where possible */
  21. #endif
  22. /* Include Files */
  23. #include <pthread.h>
  24. #include <signal.h>
  25. /* Constants & Macros */
  26. #define _SPILT_LIBERAL_DAEMON 0x0001 /* default */
  27. #define _SPILT_LIBERAL_SUSPENDED 0x0002
  28. #define _SPILT_LIBERAL_NEW_LWP 0x0004 /* default */
  29. #define _SPILT_LIBERAL_SETCONCURRENCY 0x0008 /* default */
  30. #define _SPILT_LIBERAL_GETCONCURRENCY 0x0010 /* default */
  31. #define _SPILT_LIBERAL_SUSPEND 0x0020
  32. #define _SPILT_LIBERAL_CONTINUE 0x0040
  33. #define _SPILT_LIBERAL_BOUND 0x0080
  34. #define _SPILT_LIBERAL_STACKADDR 0x0100 /* default */
  35. #define _SPILT_LIBERAL_STACKSIZE 0x0200 /* default */
  36. #define _SPILT_LIBERAL_SETPRIO 0x0400 /* default */
  37. #define _SPILT_LIBERAL_GETPRIO 0x0800 /* default */
  38. #define _SPILT_LIBERAL_DEFAULT (0x0f1d)
  39. #define SPILT_LIBERAL _SPILT_LIBERAL_DEFAULT
  40. #if defined(SPILT_MACROS)
  41. # define thread_t pthread_t
  42. # define thread_key_t pthread_key_t
  43. # define thr_self pthread_self
  44. # define thr_exit pthread_exit
  45. # define thr_yield sched_yield
  46. # define thr_sigsetmask pthread_sigmask
  47. # define thr_kill pthread_kill
  48. # define thr_keycreate pthread_key_create
  49. # define thr_setspecific pthread_setspecific
  50. #endif /* SPILT_MACROS */
  51. #define THR_DAEMON 0x0001
  52. #define THR_NEW_LWP 0x0002
  53. #define THR_BOUND 0x0004
  54. #define THR_SUSPENDED 0x0008
  55. #define THR_DETACHED 0x0010
  56. /* Data Declarations */
  57. #if !defined(SPILT_MACROS)
  58. typedef pthread_t thread_t;
  59. typedef pthread_key_t thread_key_t;
  60. #endif /* SPILT_MACROS */
  61. /* External References */
  62. #if defined(__cplusplus)
  63. extern "C" {
  64. #endif
  65. extern int thr_create( void *, size_t, void *(*)( void * ), void *, long, thread_t * );
  66. extern size_t thr_min_stack( void );
  67. #if !defined(SPILT_MACROS)
  68. extern thread_t thr_self( void );
  69. extern void thr_exit( void * );
  70. #endif /* SPILT_MACROS */
  71. extern int thr_join( thread_t, thread_t *, void ** );
  72. extern int thr_setprio( thread_t, int  );
  73. extern int thr_getprio( thread_t, int * );
  74. extern int thr_suspend( thread_t );
  75. extern int thr_continue( thread_t );
  76. extern int thr_setconcurrency( int );
  77. extern int thr_getconcurrency( void );
  78. #if !defined(SPILT_MACROS)
  79. extern int thr_yield( void );
  80. extern int thr_sigsetmask( int, const sigset_t *, sigset_t * );
  81. extern int thr_kill( thread_t, int );
  82. extern int thr_keycreate( thread_key_t *, void (*)( void * ) );
  83. extern int thr_setspecific( thread_key_t, void * );
  84. #endif /* SPILT_MACROS */
  85. extern int thr_getspecific( thread_key_t, void ** );
  86. #if defined(__cplusplus)
  87. }
  88. #endif
  89. #endif /* THREAD_INCLUDED */