2 * Copyright (c) International Business Machines Corp., 2001-2004
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* #define RWDEBUG 1 */
25 /* n_readers >= 0 means 0 or more readers */
26 /* n_readers < 0 means a writer */
28 pthread_mutex_t plock;
38 void init_rwlock(struct rwlock *rw);
40 void rw_lock_read(struct rwlock *rw);
41 void rw_lock_write(struct rwlock *rw);
43 void rw_unlock_read(struct rwlock *rw);
44 void rw_unlock_write(struct rwlock *rw);
46 int rw_trylock_read(struct rwlock *rw);
47 int rw_trylock_write(struct rwlock *rw);