ncurses 5.6 - patch 20080308
[ncurses.git] / ncurses / base / use_window.c
index 5ef07c8288d1741e5020d76aad0233495282fb91..578dff3aecfbe4c96304766154c932b988eb6b9f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2007,2008 Free Software Foundation, Inc.                   *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: use_window.c,v 1.1 2007/09/08 21:35:33 tom Exp $")
+MODULE_ID("$Id: use_window.c,v 1.4 2008/03/02 11:42:37 tom Exp $")
+
+#ifdef USE_PTHREADS
+NCURSES_EXPORT(void)
+_nc_lock_window(WINDOW *win)
+{
+    WINDOWLIST *p;
+
+    _nc_lock_global(windowlist);
+    for (p = _nc_windows; p != 0; p = p->next) {
+       if (&(p->win) == win) {
+           _nc_mutex_lock(&(p->mutex_use_window));
+           break;
+       }
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_unlock_window(WINDOW *win)
+{
+    WINDOWLIST *p;
+
+    for (p = _nc_windows; p != 0; p = p->next) {
+       if (&(p->win) == win) {
+           _nc_mutex_unlock(&(p->mutex_use_window));
+           break;
+       }
+    }
+    _nc_unlock_global(windowlist);
+}
+#endif
 
 NCURSES_EXPORT(int)
 use_window(WINDOW *win, NCURSES_CALLBACK func, void *data)
@@ -43,5 +73,6 @@ use_window(WINDOW *win, NCURSES_CALLBACK func, void *data)
     _nc_lock_window(win);
     code = func(win, data);
     _nc_unlock_window(win);
+
     returnCode(code);
 }