~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to mit-pthreads/machdep/engine-i386-linux-2.0.h

  • Committer: bk at mysql
  • Date: 2000-07-31 19:29:14 UTC
  • Revision ID: sp1r-bk@work.mysql.com-20000731192914-08846
Import changeset

Show diffs side-by-side

added added

removed removed

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