engine-hppa-hpux-9.03.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* ==== machdep.c ============================================================
  2.  * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
  3.  *
  4.  * Description : Machine dependent functions for HP-UX 9.03 on hppa
  5.  *
  6.  * 1.00 93/12/14 proven
  7.  *      -Started coding this file.
  8.  */
  9. #include <pthread.h>
  10. #include <setjmp.h>
  11. #include <stdlib.h>
  12. #include <unistd.h>
  13. /* ==========================================================================
  14.  * machdep_save_state()
  15.  */
  16. int machdep_save_state(void)
  17. {
  18.     return(setjmp(pthread_run->machdep_data.machdep_state));
  19. }
  20. /* ==========================================================================
  21.  * machdep_restore_state()
  22.  */
  23. void machdep_restore_state(void)
  24. {
  25.     longjmp(pthread_run->machdep_data.machdep_state, 1);
  26. }
  27. /* ==========================================================================
  28.  * machdep_save_float_state()
  29.  */
  30. void machdep_save_float_state(struct pthread * pthread)
  31. {
  32. return;
  33. }
  34. /* ==========================================================================
  35.  * machdep_restore_float_state()
  36.  */
  37. void machdep_restore_float_state()
  38. {
  39.    return;
  40. }
  41. /* ==========================================================================
  42.  * machdep_set_thread_timer()
  43.  */
  44. void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
  45. {
  46.     if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
  47.         PANIC();
  48.     }
  49. }
  50. /* ==========================================================================
  51.  * machdep_unset_thread_timer()
  52.  */
  53. void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
  54. {
  55.     struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
  56.     if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
  57.         PANIC();
  58.     }
  59. }
  60. /* ==========================================================================
  61.  * machdep_pthread_cleanup()
  62.  */
  63. void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
  64. {
  65.     return(machdep_pthread->machdep_stack);
  66. }
  67. /* ==========================================================================
  68.  * machdep_pthread_start()
  69.  */
  70. void machdep_pthread_start(void)
  71. {
  72. context_switch_done();
  73. pthread_sched_resume();
  74.     /* Run current threads start routine with argument */
  75.     pthread_exit(pthread_run->machdep_data.start_routine
  76.       (pthread_run->machdep_data.start_argument));
  77.     /* should never reach here */
  78.     PANIC();
  79. }
  80. /* ==========================================================================
  81.  * __machdep_stack_free()
  82.  */
  83. void __machdep_stack_free(void * stack)
  84. {       
  85.     free(stack);
  86. }
  87.  
  88. /* ==========================================================================
  89.  * __machdep_stack_alloc()
  90.  */ 
  91. void * __machdep_stack_alloc(size_t size)
  92. {   
  93.     void * stack;
  94.     
  95.     return(malloc(size));
  96. }     
  97.     
  98. /* ==========================================================================
  99.  * __machdep_pthread_create()
  100.  */
  101. void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
  102.   void *(* start_routine)(), void *start_argument, 
  103.   long stack_size, long nsec, long flags)
  104. {
  105.     machdep_pthread->start_routine = start_routine;
  106.     machdep_pthread->start_argument = start_argument;
  107.     machdep_pthread->machdep_timer.it_value.tv_sec = 0;
  108.     machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
  109.     machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
  110.     machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
  111.     setjmp(machdep_pthread->machdep_state);
  112.     /*
  113.      * Set up new stact frame so that it looks like it
  114.      * returned from a longjmp() to the beginning of
  115.      * machdep_pthread_start().
  116.      */
  117.     ((int *)machdep_pthread->machdep_state)[0] = (int)machdep_pthread_start;
  118.     /* Stack starts low and builds up, but needs two start frames */
  119.     ((int *)machdep_pthread->machdep_state)[1] =
  120.       (int)machdep_pthread->machdep_stack + (64 * 2);
  121. }
  122. int machdep_sys_getdtablesize()
  123. {
  124. return sysconf(_SC_OPEN_MAX);
  125. }
  126. void sig_check_and_resume()
  127. {
  128.   return;
  129. }
  130. void ___exit(int status)
  131. {
  132. exit(status);
  133.         PANIC();
  134. }