Print this page
5910 libnisdb won't build with modern GCC

*** 18,33 **** * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2001 by Sun Microsystems, Inc. * All rights reserved. */ - #pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <rpc/types.h> #include <rpc/xdr.h> #include "db_dictionary_c.h" #include "nisdb_rw.h" --- 18,32 ---- * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* + * Copyright 2015 Gary Mills * Copyright (c) 2001 by Sun Microsystems, Inc. * All rights reserved. */ #include <stdio.h> #include <rpc/types.h> #include <rpc/xdr.h> #include "db_dictionary_c.h" #include "nisdb_rw.h"
*** 105,116 **** int __nisdb_rw_readlock_ok(__nisdb_rwlock_t *rw) { int ret; - pthread_t myself = pthread_self(); - __nisdb_rl_t *rr; if (rw == 0) return (EFAULT); if (rw->destroyed != 0) --- 104,113 ----
*** 137,148 **** int __nisdb_rw_force_writelock(__nisdb_rwlock_t *rw) { int ret; - pthread_t myself = pthread_self(); - __nisdb_rl_t *rr; if (rw == 0 || rw->destroyed != 0) return (ESHUTDOWN); if ((ret = mutex_lock(&rw->mutex)) != 0) --- 134,143 ----
*** 204,224 **** * Need to know if we're holding a read lock already, and if * all other readers are blocked waiting for the mutex. */ if (rw->reader_count > 0) { if ((rr = find_reader(myself, rw)) != 0) { ! if (rr->count) /* * We're already holding a read lock, so * if the number of readers equals the number * of blocked readers plus one, all other * readers are blocked. */ if (rw->reader_count == (rw->reader_blocked + 1)) all_readers_blocked = 1; ! else /* * We're not holding a read lock, so the * number of readers should equal the number * of blocked readers if all readers are * blocked. --- 199,219 ---- * Need to know if we're holding a read lock already, and if * all other readers are blocked waiting for the mutex. */ if (rw->reader_count > 0) { if ((rr = find_reader(myself, rw)) != 0) { ! if (rr->count) { /* * We're already holding a read lock, so * if the number of readers equals the number * of blocked readers plus one, all other * readers are blocked. */ if (rw->reader_count == (rw->reader_blocked + 1)) all_readers_blocked = 1; ! } else { /* * We're not holding a read lock, so the * number of readers should equal the number * of blocked readers if all readers are * blocked.
*** 225,234 **** --- 220,230 ---- */ if (rw->reader_count == rw->reader_blocked) all_readers_blocked = 1; } } + } /* Wait for reader(s) or writer to finish */ while (1) { /* * We can stop looping if one of the following holds:
*** 238,249 **** * - One reader, and it's us * - N readers, but all blocked on the mutex */ if ( (rw->writer_count == 0 && rw->reader_count == 0) || ! ((rw->writer_count == 0 || rw->writer.id == myself) && ! (rw->reader_count == 0) || (rw->reader_count == 1 && rw->reader.id == myself))) { break; } /* --- 234,245 ---- * - One reader, and it's us * - N readers, but all blocked on the mutex */ if ( (rw->writer_count == 0 && rw->reader_count == 0) || ! (((rw->writer_count == 0 || rw->writer.id == myself) && ! (rw->reader_count == 0)) || (rw->reader_count == 1 && rw->reader.id == myself))) { break; } /*
*** 646,656 **** int __nisdb_destroy_lock(__nisdb_rwlock_t *rw) { int ret; pthread_t myself = pthread_self(); - __nisdb_rl_t *rr; if (rw == 0) { #ifdef NISDB_MT_DEBUG abort(); --- 642,651 ----
*** 672,683 **** /* * Only proceed if if there are neither readers nor writers * other than this thread. Also, no nested locks may be in * effect. */ ! if ((rw->writer_count > 0 && ! (rw->writer.id != myself || rw->writer.count != 1) || (rw->reader_count > 0 && !(rw->reader_count == 1 && rw->reader.id == myself && rw->reader.count == 1))) || (rw->writer_count > 0 && rw->reader_count > 0)) { #ifdef NISDB_MT_DEBUG --- 667,678 ---- /* * Only proceed if if there are neither readers nor writers * other than this thread. Also, no nested locks may be in * effect. */ ! if (((rw->writer_count > 0 && ! (rw->writer.id != myself || rw->writer.count != 1)) || (rw->reader_count > 0 && !(rw->reader_count == 1 && rw->reader.id == myself && rw->reader.count == 1))) || (rw->writer_count > 0 && rw->reader_count > 0)) { #ifdef NISDB_MT_DEBUG