[AD] pthread event handling

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


OK, here's a slightly tidied up patch for adding pthread event
handling to the X version.  The low level stuff can also be used
by timer handlers and the Linux keyboard and mouse handlers, which
all currently hook into the sigalrm system.  I haven't
implemented any of those yet though.

As far as the X event handling goes, this seems to work really
well.  This is also everything needed to remove allegro_gl_begin
and allegro_gl_end from AllegroGL!  Hooray.

AFAICS this is all safe at the moment.  The demo game runs fine
(though that's not much proof that it's all OK).

Currently the threaded background event manager thingy is
cycling through registered background functions, calling each in
turn, and waiting for 10ms between them.  The 10ms wait is there
to stop it going wild -- it can totally drown out other CPU
tasks, like the main game thread.  This is by no means an ideal
way to control the thread though -- it would be better to
support selecting on fds or (ideally) let the background
routines block if they want to.  The latter would need a
different system -- one thread per background function, instead
of one thread for all of them.  For things that can be selected
on, this would work well, but some things (like responding to X
events) can't be selected on, so they'd continue using a system
like this one.

The X code now does not use ENABLE and DISABLE -- it uses XLOCK
and XUNLOCK, which are defined in aintunix.h (where ENABLE and
DISABLE are defined).  I'm not sure whether these are useful to
users, but they are used by both xwin.c and xdga2.c.  If the
user uses XLockDisplay and XUnlockDisplay, and pthreads is
available, then they don't need to use these macros.

Regarding Angello's QNX port, it could use this system for its
background processing, but it's effectively the same as the way
Angello is doing it already so there may not be much point.  The
two are compatible, in any case -- shared Unix components using
my system won't interfere with his system.

If there are no objections, I'll commit these things sometime
soon.

George

-- 
Random project update:
22/06/2000: AllegroGL documentation:  http://allegrogl.sourceforge.net/
        See under `Documentation' for the AllegroGL Reference Manual in
        various formats.

Index: makefile.lst
===================================================================
RCS file: /cvsroot/alleg/allegro/makefile.lst,v
retrieving revision 1.26
diff -u -r1.26 makefile.lst
--- makefile.lst	2001/04/30 07:59:02	1.26
+++ makefile.lst	2001/05/07 20:58:07
@@ -269,7 +269,8 @@
 	src/unix/usnddrv.c \
 	src/unix/usystem.c \
 	src/unix/utimer.c \
-	src/misc/ufile.c
+	src/misc/ufile.c \
+	src/unix/uthreads.c
 
 ALLEGRO_SRC_X_FILES = \
 	src/x/xgfxdrv.c \
Index: include/xalleg.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/xalleg.h,v
retrieving revision 1.7
diff -u -r1.7 xalleg.h
--- include/xalleg.h	2001/04/21 01:05:06	1.7
+++ include/xalleg.h	2001/05/07 20:58:15
@@ -58,6 +58,7 @@
 extern struct _xwin_type
 {
    Display *display;
+   volatile int lock_count;
    int screen;
    Window window;
    GC gc;
Index: include/allegro/aintunix.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/aintunix.h,v
retrieving revision 1.6
diff -u -r1.6 aintunix.h
--- include/allegro/aintunix.h	2001/04/24 17:03:53	1.6
+++ include/allegro/aintunix.h	2001/05/07 20:58:15
@@ -78,6 +78,26 @@
    AL_ARRAY(_DRIVER_INFO, _xwin_timer_driver_list);
 
    AL_FUNC(void, _xwin_handle_input, (void));
+
+
+	#define XLOCK() \
+		if (_xwin_bg_man->multi_threaded) { \
+			if (_xwin.display) { \
+				XLockDisplay (_xwin.display); \
+			} \
+		} else { \
+			_xwin.lock_count++; \
+		}
+
+	#define XUNLOCK() \
+		if (_xwin_bg_man->multi_threaded) { \
+			if (_xwin.display) { \
+				XUnlockDisplay (_xwin.display); \
+			} \
+		} else { \
+			_xwin.lock_count--; \
+		}
+
 #endif
 
 
@@ -91,6 +111,29 @@
 #ifdef ALLEGRO_LINUX
    #include "aintlnx.h"
 #endif
+
+
+/* Typedef for background functions, called frequently in the background.
+ * `threaded' is nonzero if the function is being called from a thread.
+ */
+typedef void (*bg_func) (int threaded);
+
+/* Background function manager -- responsible for calling background 
+ * functions.  `int' methods return -1 on failure, 0 on success. */
+struct bg_manager
+{
+	int multi_threaded;
+	int (*init) (void);
+	void (*exit) (void);
+	int (*register_func) (bg_func f);
+	int (*unregister_func) (bg_func f);
+};	
+
+extern struct bg_manager _bg_man_pthreads;
+extern struct bg_manager _bg_man_sigalrm;
+
+extern struct bg_manager *_xwin_bg_man;
+
 
 #ifdef __cplusplus
 }
Index: src/unix/usigalrm.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/usigalrm.c,v
retrieving revision 1.3
diff -u -r1.3 usigalrm.c
--- src/unix/usigalrm.c	2001/04/24 17:06:28	1.3
+++ src/unix/usigalrm.c	2001/05/07 20:58:16
@@ -274,3 +274,76 @@
    _sigalrm_already_installed = FALSE;
 }
 
+
+/*============================================================
+ * SIGALRM bg_manager
+ *-----------------------------------------------------------*/
+
+static void (*bg_man_sigalrm_handler_chain) (unsigned long);
+static int bg_man_sigalrm_installed;
+
+#define MAX_FUNCS 16
+static bg_func funcs[MAX_FUNCS];
+static int max_func; /* highest+1 used entry */
+
+static void bg_man_sigalrm_handler (unsigned long interval)
+{
+	int i;
+	bg_man_sigalrm_handler_chain (interval);
+	for (i = 0; i < max_func; i++)
+		if (funcs[i]) funcs[i](0);
+}
+
+static int bg_man_sigalrm_init (void)
+{
+	if (!_sigalrm_already_installed) return -1; // must install sigalrm first
+	if (bg_man_sigalrm_installed++) return 0;
+	bg_man_sigalrm_handler_chain = _sigalrm_interrupt_handler;
+	_sigalrm_interrupt_handler = bg_man_sigalrm_handler;
+	return 0;
+}
+
+static void bg_man_sigalrm_exit (void)
+{
+	if (!bg_man_sigalrm_installed) return;
+	if (--bg_man_sigalrm_installed) return;
+	_sigalrm_interrupt_handler = bg_man_sigalrm_handler_chain;
+}
+
+static int bg_man_sigalrm_register_func (bg_func f)
+{
+	int i;
+	for (i = 0; funcs[i] && i < MAX_FUNCS; i++);
+	if (i == MAX_FUNCS) return -1;
+
+	funcs[i] = f;
+
+	if (i == max_func) max_func++;
+
+	return 0;
+}
+
+static int bg_man_sigalrm_unregister_func (bg_func f)
+{
+	int i;
+	for (i = 0; funcs[i] != f && i < max_func; i++);
+	if (i == max_func) return -1;
+
+	funcs[i] = NULL;
+
+	if (i+1 == max_func)
+		do {
+			max_func--;
+		} while (!funcs[max_func] && max_func > 0);
+
+	return 0;
+}
+
+struct bg_manager _bg_man_sigalrm = {
+	0,
+	bg_man_sigalrm_init,
+	bg_man_sigalrm_exit,
+	bg_man_sigalrm_register_func,
+	bg_man_sigalrm_unregister_func
+};
+
Index: src/x/xdga2.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xdga2.c,v
retrieving revision 1.7
diff -u -r1.7 xdga2.c
--- src/x/xdga2.c	2001/04/12 05:21:56	1.7
+++ src/x/xdga2.c	2001/05/07 20:58:19
@@ -456,9 +456,9 @@
 BITMAP *_xdga2_gfxdrv_init_drv(GFX_DRIVER *drv, int w, int h, int vw, int vh, int depth, int accel)
 {
    BITMAP *bmp;
-   DISABLE();
+   XLOCK();
    bmp = _xdga2_private_gfxdrv_init_drv(drv, w, h, vw, vh, depth, accel);
-   ENABLE();
+   XUNLOCK();
    if (!bmp)
       _xdga2_gfxdrv_exit(bmp);
    return bmp;
@@ -471,7 +471,7 @@
  */
 void _xdga2_gfxdrv_exit(BITMAP *bmp)
 {
-   DISABLE();
+   XLOCK();
    
    if (_xwin.in_dga_mode) {
       XDGACloseFramebuffer(_xwin.display, _xwin.screen);
@@ -489,7 +489,7 @@
 
    }
    
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -501,9 +501,9 @@
 {
    int result;
 
-   DISABLE();
+   XLOCK();
    result = XDGAGetViewportStatus(_xwin.display, _xwin.screen);
-   ENABLE();
+   XUNLOCK();
    return result;
 }
 
@@ -514,7 +514,7 @@
  */
 int _xdga2_request_scroll(int x, int y)
 {
-   DISABLE();
+   XLOCK();
    
    if (x < 0) x = 0;
    else if (x > dga_device->mode.maxViewportX)
@@ -525,7 +525,7 @@
 
    XDGASetViewport(_xwin.display, _xwin.screen, x, y, XDGAFlipRetrace);
 
-   ENABLE();
+   XUNLOCK();
    
    return 0;
 }
@@ -537,9 +537,9 @@
  */
 int _xdga2_request_video_bitmap(BITMAP *bmp)
 {
-   DISABLE();
+   XLOCK();
    XDGASetViewport(_xwin.display, _xwin.screen, bmp->x_ofs, bmp->y_ofs, XDGAFlipRetrace);
-   ENABLE();
+   XUNLOCK();
    return 0;
 }
 
@@ -550,7 +550,7 @@
  */
 int _xdga2_scroll_screen(int x, int y)
 {
-   DISABLE();
+   XLOCK();
    
    if (x < 0) x = 0;
    else if (x > dga_device->mode.maxViewportX)
@@ -562,7 +562,7 @@
    while (XDGAGetViewportStatus(_xwin.display, _xwin.screen));
    XDGASetViewport(_xwin.display, _xwin.screen, x, y, XDGAFlipRetrace);
 
-   ENABLE();
+   XUNLOCK();
    
    return 0;
 }
@@ -577,7 +577,7 @@
    int i;
    static XColor color[256];
 
-   DISABLE();
+   XLOCK();
    
    if (vsync) {
       XSync(_xwin.display, False);
@@ -595,7 +595,7 @@
       XSync(_xwin.display, False);
    }
 
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -605,9 +605,9 @@
  */
 static void _xdga2_acquire(BITMAP *bmp)
 {
-   DISABLE();
+   XLOCK();
    RESYNC();
-   ENABLE();
+   XUNLOCK();
    bmp->id |= BMP_ID_LOCKED;
 }
 
@@ -619,9 +619,9 @@
 unsigned long _xdga2_write_line(BITMAP *bmp, int line)
 {
    if (!(bmp->id & BMP_ID_LOCKED)) {
-      DISABLE();
+      XLOCK();
       RESYNC();
-      ENABLE();
+      XUNLOCK();
       bmp->id |= BMP_ID_LOCKED;
    }
    return (unsigned long)(bmp->line[line]);
@@ -665,9 +665,9 @@
    y += bmp->y_ofs;
    x2 += bmp->x_ofs;
 
-   DISABLE();
+   XLOCK();
    XDGAFillRectangle(_xwin.display, _xwin.screen, x1, y, (x2 - x1) + 1, 1, color);
-   ENABLE();
+   XUNLOCK();
    bmp->id &= ~BMP_ID_LOCKED;
 }
 
@@ -709,9 +709,9 @@
    y1 += bmp->y_ofs;
    y2 += bmp->y_ofs;
 
-   DISABLE();
+   XLOCK();
    XDGAFillRectangle(_xwin.display, _xwin.screen, x, y1, 1, (y2 - y1) + 1, color);
-   ENABLE();
+   XUNLOCK();
    bmp->id &= ~BMP_ID_LOCKED;
 }
 
@@ -766,9 +766,9 @@
    x2 += bmp->x_ofs;
    y2 += bmp->y_ofs;
 
-   DISABLE();
+   XLOCK();
    XDGAFillRectangle(_xwin.display, _xwin.screen, x1, y1, (x2 - x1) + 1, (y2 - y1) + 1, color);
-   ENABLE();
+   XUNLOCK();
    bmp->id &= ~BMP_ID_LOCKED;
 }
 
@@ -786,9 +786,9 @@
    x2 = bmp->cr + bmp->x_ofs;
    y2 = bmp->cb + bmp->y_ofs;
    
-   DISABLE();
+   XLOCK();
    XDGAFillRectangle(_xwin.display, _xwin.screen, x1, y1, x2 - x1, y2 - y1, color);
-   ENABLE();
+   XUNLOCK();
    bmp->id &= ~BMP_ID_LOCKED;
 }
 
@@ -804,9 +804,9 @@
    dest_x += dest->x_ofs;
    dest_y += dest->y_ofs;
 
-   DISABLE();
+   XLOCK();
    XDGACopyArea(_xwin.display, _xwin.screen, source_x, source_y, width, height, dest_x, dest_y);
-   ENABLE();
+   XUNLOCK();
    dest->id &= ~BMP_ID_LOCKED;
 }
 
@@ -856,9 +856,9 @@
       x += bmp->x_ofs;
       y += bmp->y_ofs;
 
-      DISABLE();
+      XLOCK();
       XDGACopyTransparentArea(_xwin.display, _xwin.screen, sx, sy, w, h, x, y, sprite->vtable->mask_color);
-      ENABLE();
+      XUNLOCK();
       bmp->id &= ~BMP_ID_LOCKED;
    }
    else
@@ -878,9 +878,9 @@
       dest_x += dest->x_ofs;
       dest_y += dest->y_ofs;
 
-      DISABLE();
+      XLOCK();
       XDGACopyTransparentArea(_xwin.display, _xwin.screen, source_x, source_y, width, height, dest_x, dest_y, source->vtable->mask_color);
-      ENABLE();
+      XUNLOCK();
       dest->id &= ~BMP_ID_LOCKED;
    }
    else
Index: src/x/xkeybd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xkeybd.c,v
retrieving revision 1.4
diff -u -r1.4 xkeybd.c
--- src/x/xkeybd.c	2001/04/09 05:04:58	1.4
+++ src/x/xkeybd.c	2001/05/07 20:58:19
@@ -145,12 +145,12 @@
    _xwin_init_keyboard_tables();
    _xwin_keydrv_set_leds(_key_shifts);
 
-   DISABLE();
+   XLOCK();
 
    _xwin_keyboard_interrupt = _xwin_keydrv_handler;
    _xwin_keyboard_focused = _xwin_keydrv_focused;
 
-   ENABLE();
+   XUNLOCK();
 
    return 0;
 }
@@ -162,11 +162,11 @@
  */
 static void _xwin_keydrv_exit(void)
 {
-   DISABLE();
+   XLOCK();
 
    _xwin_keyboard_interrupt = 0;
    _xwin_keyboard_focused = 0;
 
-   ENABLE();
+   XUNLOCK();
 }
 
Index: src/x/xmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xmouse.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 xmouse.c
--- src/x/xmouse.c	2000/05/14 20:17:19	1.1.1.1
+++ src/x/xmouse.c	2001/05/07 20:58:19
@@ -104,11 +104,11 @@
    num_buttons = _xwin_get_pointer_mapping(map, sizeof(map));
    num_buttons = MID(2, num_buttons, 3);
 
-   DISABLE();
+   XLOCK();
 
    _xwin_mouse_interrupt = _xwin_mousedrv_handler;
 
-   ENABLE();
+   XUNLOCK();
 
    return num_buttons;
 }
@@ -120,11 +120,11 @@
  */
 static void _xwin_mousedrv_exit(void)
 {
-   DISABLE();
+   XLOCK();
 
    _xwin_mouse_interrupt = 0;
 
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -134,14 +134,14 @@
  */
 static void _xwin_mousedrv_position(int x, int y)
 {
-   DISABLE();
+   XLOCK();
 
    _mouse_x = x;
    _mouse_y = y;
 
    mymickey_x = mymickey_y = 0;
 
-   ENABLE();
+   XUNLOCK();
 
    _xwin_set_warped_mouse_mode(FALSE);
 }
@@ -158,12 +158,12 @@
    mouse_maxx = x2;
    mouse_maxy = y2;
 
-   DISABLE();
+   XLOCK();
 
    _mouse_x = MID(mouse_minx, _mouse_x, mouse_maxx);
    _mouse_y = MID(mouse_miny, _mouse_y, mouse_maxy);
 
-   ENABLE();
+   XUNLOCK();
 }
 
 
Index: src/x/xsystem.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xsystem.c,v
retrieving revision 1.10
diff -u -r1.10 xsystem.c
--- src/x/xsystem.c	2001/05/06 21:52:35	1.10
+++ src/x/xsystem.c	2001/05/07 20:58:20
@@ -49,6 +49,9 @@
 static _DRIVER_INFO *_xwin_sysdrv_timer_drivers(void);
 
 
+struct bg_manager *_xwin_bg_man;
+
+
 /* the main system driver for running under X-Windows */
 SYSTEM_DRIVER system_xwin =
 {
@@ -142,12 +145,18 @@
 {
    if (_unix_timer_interrupt)
       (*_unix_timer_interrupt)(interval);
+}
 
+
+/* _xwin_bg_handler:
+ *  Really used for synchronous stuff
+ */
+static void _xwin_bg_handler (int threaded)
+{
    _xwin_handle_input();
 }
 
 
-
 /* _xwin_sysdrv_init:
  *  Top level system driver wakeup call.
  */
@@ -169,13 +178,34 @@
    old_sig_quit = signal(SIGQUIT, _xwin_signal_handler);
 #endif
 
+#ifdef HAVE_LIBPTHREAD
+   _xwin_bg_man = &_bg_man_pthreads;
+#else
+   _xwin_bg_man = &_bg_man_sigalrm;
+#endif
+
+   /* Initialise sigalrm before bg_man, in case bg_man depends on sigalrm */
+   if (_sigalrm_init(_xwin_interrupts_handler)
+        || _xwin_bg_man->init()) {
+      _xwin_sysdrv_exit();
+      return -1;
+   }
+   /* If multithreaded bg_man, need to init X's lock/unlock facility. 
+    * Note that no X calls must be made before this point! */
+   if (_xwin_bg_man->multi_threaded) {
+      printf ("XInitThreads\n");
+      XInitThreads();
+   }
+
    get_executable_name(tmp, sizeof(tmp));
    set_window_title(get_filename(tmp));
 
+   /* Open the display, create a window, and background-process 
+    * events for it all. */
    if (_xwin_open_display(0) || _xwin_create_window()
-       || _sigalrm_init(_xwin_interrupts_handler)) {
-      _xwin_sysdrv_exit();
-      return -1;
+       || _xwin_bg_man->register_func (_xwin_bg_handler)) {
+	 _xwin_sysdrv_exit();
+	 return -1;
    }
 
    set_display_switch_mode(SWITCH_BACKGROUND);
@@ -190,10 +220,9 @@
  */
 static void _xwin_sysdrv_exit(void)
 {
+   _xwin_bg_man->exit();
    _sigalrm_exit();
-
    _xwin_destroy_window();
-
    _xwin_close_display();
 
    signal(SIGABRT, old_sig_abrt);
Index: src/x/xwin.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xwin.c,v
retrieving revision 1.22
diff -u -r1.22 xwin.c
--- src/x/xwin.c	2001/04/21 01:05:06	1.22
+++ src/x/xwin.c	2001/05/07 20:58:27
@@ -55,6 +55,7 @@
 struct _xwin_type _xwin =
 {
    0,           /* display */
+   0,           /* lock count */
    0,           /* screen */
    None,        /* window */
    None,        /* gc */
@@ -312,9 +313,9 @@
 int _xwin_open_display(char *name)
 {
    int result;
-   DISABLE();
+   XLOCK();
    result = _xwin_private_open_display(name);
-   ENABLE();
+   XUNLOCK();
    return result;
 }
 
@@ -335,9 +336,9 @@
 
 void _xwin_close_display(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_close_display();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -432,9 +433,9 @@
 int _xwin_create_window(void)
 {
    int result;
-   DISABLE();
+   XLOCK();
    result = (*_xwin_window_creator)();
-   ENABLE();
+   XUNLOCK();
    return result;
 }
 
@@ -478,9 +479,9 @@
 
 void _xwin_destroy_window(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_destroy_window();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -760,11 +761,11 @@
 			    int vw, int vh, int depth, int fullscreen)
 {
    BITMAP *bmp;
-   DISABLE();
+   XLOCK();
    bmp = _xwin_private_create_screen(drv, w, h, vw, vh, depth, fullscreen);
    if (bmp == 0)
       _xwin_private_destroy_screen();
-   ENABLE();
+   XUNLOCK();
    return bmp;
 }
 
@@ -822,9 +823,9 @@
 
 void _xwin_destroy_screen(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_destroy_screen();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -1829,9 +1830,9 @@
 
 void _xwin_set_palette_range(AL_CONST PALETTE p, int from, int to, int vsync)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_set_palette_range(p, from, to, vsync);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -1874,9 +1875,9 @@
 
 void _xwin_flush_buffers(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_flush_buffers();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -1894,9 +1895,9 @@
 
 void _xwin_vsync(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_vsync();
-   ENABLE();
+   XUNLOCK();
 
    if (_timer_installed) {
       int prev = retrace_count;
@@ -2206,8 +2207,10 @@
 
 void _xwin_handle_input(void)
 {
-   DISABLE();
+   if (_xwin.lock_count) return;
 
+   XLOCK();
+
 #ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA2
    if (_xwin.in_dga_mode == 2)
       _xdga2_handle_input();
@@ -2215,7 +2218,7 @@
 #endif
    _xwin_private_handle_input();
 
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2230,9 +2233,9 @@
 
 void _xwin_set_warped_mouse_mode(int permanent)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_set_warped_mouse_mode(permanent);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2289,9 +2292,9 @@
 
 void _xwin_redraw_window(int x, int y, int w, int h)
 {
-   DISABLE();
+   XLOCK();
    (*_xwin_window_redrawer)(x, y, w, h);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2321,9 +2324,9 @@
 int _xwin_scroll_screen(int x, int y)
 {
    int result;
-   DISABLE();
+   XLOCK();
    result = _xwin_private_scroll_screen(x, y);
-   ENABLE();
+   XUNLOCK();
    return result;
 }
 
@@ -2367,9 +2370,9 @@
 
 void _xwin_update_screen(int x, int y, int w, int h)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_update_screen(x, y, w, h);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2390,9 +2393,9 @@
 
 void _xwin_set_window_title(AL_CONST char *name)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_set_window_title(name);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2415,9 +2418,9 @@
 
 void _xwin_change_keyboard_control(int led, int on)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_change_keyboard_control(led, on);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2433,9 +2436,9 @@
 int _xwin_get_pointer_mapping(unsigned char map[], int nmap)
 {
    int num;
-   DISABLE();
+   XLOCK();
    num = _xwin_private_get_pointer_mapping(map, nmap);
-   ENABLE();
+   XUNLOCK();
    return num;
 }
 
@@ -2627,9 +2630,9 @@
 
 void _xwin_init_keyboard_tables(void)
 {
-   DISABLE();
+   XLOCK();
    _xwin_private_init_keyboard_tables();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -2952,13 +2955,13 @@
 BITMAP *_xdga_create_screen(GFX_DRIVER *drv, int w, int h, int vw, int vh, int depth, int fullscreen)
 {
    BITMAP *bmp;
-   DISABLE();
+   XLOCK();
    bmp = _xdga_private_create_screen(drv, w, h, vw, vh, depth, fullscreen);
    if (bmp == 0)
       _xdga_private_destroy_screen();
    else
       _mouse_on = TRUE;
-   ENABLE();
+   XUNLOCK();
    return bmp;
 }
 
@@ -3016,9 +3019,9 @@
 
 void _xdga_destroy_screen(void)
 {
-   DISABLE();
+   XLOCK();
    _xdga_private_destroy_screen();
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -3074,9 +3077,9 @@
 
 void _xdga_set_palette_range(AL_CONST PALETTE p, int from, int to, int vsync)
 {
-   DISABLE();
+   XLOCK();
    _xdga_private_set_palette_range(p, from, to, vsync);
-   ENABLE();
+   XUNLOCK();
 }
 
 
@@ -3106,9 +3109,9 @@
 int _xdga_scroll_screen(int x, int y)
 {
    int result;
-   DISABLE();
+   XLOCK();
    result = _xdga_private_scroll_screen(x, y);
-   ENABLE();
+   XUNLOCK();
    return result;
 }
 #endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/