2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ---------------------------- included header files ---------------------- */
19 #define FEVENT_PRIVILEGED_ACCESS
21 #undef FEVENT_PRIVILEGED_ACCESS
26 #include "execcontext.h"
28 /* ---------------------------- local definitions -------------------------- */
30 /* ---------------------------- local macros ------------------------------- */
32 /* ---------------------------- imports ------------------------------------ */
34 /* ---------------------------- included code files ------------------------ */
36 /* ---------------------------- local types -------------------------------- */
38 /* ---------------------------- forward declarations ----------------------- */
40 /* ---------------------------- local variables ---------------------------- */
42 #undef DEBUG_EXECCONTEXT
43 #ifdef DEBUG_EXECCONTEXT
44 static exec_context_t
*x
[256];
48 /* ---------------------------- exported variables (globals) --------------- */
50 /* ---------------------------- local functions ---------------------------- */
52 static void __exc_change_context(
53 exec_context_t
*exc
, exec_context_changes_t
*ecc
,
54 exec_context_change_mask_t mask
)
58 exc
->type
= ecc
->type
;
60 if (mask
& ECC_ETRIGGER
)
62 if (ecc
->x
.etrigger
== NULL
)
64 fev_copy_last_event(&exc
->private_data
.te
);
68 exc
->private_data
.te
= *ecc
->x
.etrigger
;
70 exc
->x
.etrigger
= &(exc
->private_data
.te
);
74 exc
->w
.fw
= ecc
->w
.fw
;
80 if (mask
& ECC_WCONTEXT
)
82 exc
->w
.wcontext
= ecc
->w
.wcontext
;
84 if (mask
& ECC_MODULE
)
86 exc
->m
.module
= ecc
->m
.module
;
92 /* ---------------------------- interface functions ------------------------ */
94 const exec_context_t
*exc_create_null_context(void)
97 #ifdef DEBUG_EXECCONTEXT
101 exc
= (exec_context_t
*)safecalloc(1, sizeof(exec_context_t
));
102 #ifdef DEBUG_EXECCONTEXT
103 fprintf(stderr
, "xxx+0 ");
104 for(i
=0;i
<nx
;i
++)fprintf(stderr
," ");
106 fprintf(stderr
, "0x%08x\n", (int)exc
);
108 exc
->type
= EXCT_NULL
;
109 fev_make_null_event(&exc
->private_data
.te
, dpy
);
110 exc
->x
.etrigger
= &exc
->private_data
.te
;
111 exc
->x
.elast
= fev_get_last_event_address();
112 exc
->m
.module
= NULL
;
117 const exec_context_t
*exc_create_context(
118 exec_context_changes_t
*ecc
, exec_context_change_mask_t mask
)
122 #ifdef DEBUG_EXECCONTEXT
123 if (!(mask
& ECC_TYPE
)) abort();
125 exc
= (exec_context_t
*)exc_create_null_context();
126 __exc_change_context(exc
, ecc
, mask
);
131 const exec_context_t
*exc_clone_context(
132 const exec_context_t
*excin
, exec_context_changes_t
*ecc
,
133 exec_context_change_mask_t mask
)
136 #ifdef DEBUG_EXECCONTEXT
140 exc
= (exec_context_t
*)safemalloc(sizeof(exec_context_t
));
141 #ifdef DEBUG_EXECCONTEXT
142 fprintf(stderr
, "xxx+= ");
143 for(i
=0;i
<nx
;i
++)fprintf(stderr
," ");
145 fprintf(stderr
, "0x%08x\n", (int)exc
);
147 memcpy(exc
, excin
, sizeof(*exc
));
148 __exc_change_context(exc
, ecc
, mask
);
153 void exc_destroy_context(
154 const exec_context_t
*exc
)
156 #ifdef DEBUG_EXECCONTEXT
158 if (nx
== 0||x
[nx
-1] != exc
)abort();
160 fprintf(stderr
, "xxx-- ");
161 for(i
=0;i
<nx
;i
++)fprintf(stderr
," ");
162 fprintf(stderr
, "0x%08x\n", (int)exc
);
164 free((exec_context_t
*)exc
);