engine-sparc-sunos-4.1.3.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* ==== machdep.h ============================================================
  2.  * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
  3.  *
  4.  * $Id$
  5.  *
  6.  */
  7. #include <unistd.h>
  8. #include <setjmp.h>
  9. #include <sys/time.h>
  10. #include <sys/cdefs.h>
  11. /*
  12.  * The first machine dependent functions are the SEMAPHORES
  13.  * needing the test and set instruction.
  14.  */
  15. #define SEMAPHORE_CLEAR 0
  16. #define SEMAPHORE_SET   0xff
  17. #define SEMAPHORE_TEST_AND_SET(lock)    
  18. ({
  19. char *p = lock;
  20. long temp;                              
  21. __asm__ volatile("ldstub %1,%0"         
  22.         :"=r" (temp)         
  23.         :"m" (*p)
  24.     :"memory");                     
  25. temp;                                   
  26. })
  27. #define SEMAPHORE_RESET(lock)           
  28. {
  29. __asm__ volatile("stb %1, %0"
  30. :"=m" (*lock)
  31. :"r" (SEMAPHORE_CLEAR)
  32. :"memory");
  33. }
  34. /*
  35.  * New types
  36.  */
  37. typedef char    semaphore;
  38. /*
  39.  * sigset_t macros
  40.  */
  41. #define SIG_ANY(sig) (sig)
  42. #define SIGMAX 31
  43. /*
  44.  * New Strutures
  45.  */
  46. struct machdep_pthread {
  47.     void         *(*start_routine)(void *);
  48.     void         *start_argument;
  49.     void         *machdep_stack;
  50. struct itimerval machdep_timer;
  51.     jmp_buf      machdep_state;
  52. };
  53. /*
  54.  * Static machdep_pthread initialization values.
  55.  * For initial thread only.
  56.  */
  57. #define MACHDEP_PTHREAD_INIT    
  58. { NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
  59. /*
  60.  * Minimum stack size
  61.  */
  62. #define PTHREAD_STACK_MIN 1024
  63. /*
  64.  * Some fd flag defines that are necessary to distinguish between posix
  65.  * behavior and bsd4.3 behavior.
  66.  */
  67. #define __FD_NONBLOCK  (O_NONBLOCK | O_NDELAY)
  68. /*
  69.  * New functions
  70.  */
  71. __BEGIN_DECLS
  72. #if defined(PTHREAD_KERNEL)
  73. #define __machdep_stack_get(x)      (x)->machdep_stack
  74. #define __machdep_stack_set(x, y)   (x)->machdep_stack = y
  75. #define __machdep_stack_repl(x, y)                          
  76. {                                                           
  77.     if (stack = __machdep_stack_get(x)) {                   
  78.         __machdep_stack_free(stack);                        
  79.     }                                                       
  80.     __machdep_stack_set(x, y);                              
  81. }
  82. void *  __machdep_stack_alloc       __P_((size_t));
  83. void    __machdep_stack_free        __P_((void *));
  84. int machdep_save_state      __P_((void));
  85. #endif
  86. __END_DECLS