summaryrefslogtreecommitdiff
path: root/lib/libc_r/uthread/uthread_file.c
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-11-09 03:13:22 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-11-09 03:13:22 +0000
commitff47464de5e68e9c49fe312c953f54b2e90f546c (patch)
tree4ec0e7f13d619e1b5bf6abfd7125a4ec17569568 /lib/libc_r/uthread/uthread_file.c
parent1b2b2c2386c6cc5ebffc769b8a39b80d47e4e0d0 (diff)
sync with FreeBSD (rwlock, gc thread, man pages)
add (broken) mips md stuff fix some const warnings add sigaltstack() stub another hash at getting shlib auto-init to work (mips/elf and i386/a.out)
Diffstat (limited to 'lib/libc_r/uthread/uthread_file.c')
-rw-r--r--lib/libc_r/uthread/uthread_file.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/lib/libc_r/uthread/uthread_file.c b/lib/libc_r/uthread/uthread_file.c
index 71fecfea217..26f0835ec1c 100644
--- a/lib/libc_r/uthread/uthread_file.c
+++ b/lib/libc_r/uthread/uthread_file.c
@@ -29,8 +29,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: uthread_file.c,v 1.1 1998/08/27 09:01:02 d Exp $
- * $OpenBSD: uthread_file.c,v 1.1 1998/08/27 09:01:02 d Exp $
+ * $Id: uthread_file.c,v 1.2 1998/11/09 03:13:19 d Exp $
+ * $OpenBSD: uthread_file.c,v 1.2 1998/11/09 03:13:19 d Exp $
*
* POSIX stdio FILE locking functions. These assume that the locking
* is only required at FILE structure level, not at file descriptor
@@ -46,13 +46,6 @@
#include "pthread_private.h"
/*
- * Weak symbols for externally visible functions in this file:
- */
-#pragma weak flockfile=_flockfile
-#pragma weak ftrylockfile=_ftrylockfile
-#pragma weak funlockfile=_funlockfile
-
-/*
* The FILE lock structure. The FILE *fp is locked if the owner is
* not NULL. If not locked, the file lock structure can be
* reassigned to a different file by setting fp.
@@ -83,7 +76,7 @@ struct file_lock {
* structures. If there is a collision, a linear search of the
* dynamic list of locks linked to each static lock is perfomed.
*/
-#define file_idx(_p) ((((long) _p) >> sizeof(void *)) % NUM_HEADS)
+#define file_idx(_p) ((((u_long) _p) >> sizeof(void *)) % NUM_HEADS)
/*
* Global array of file locks. The first lock for each hash bucket is
@@ -123,7 +116,7 @@ find_lock(int idx, FILE *fp)
* Loop through the dynamic locks looking for the
* target file:
*/
- while (p != NULL && p->fp != fp && p->owner != NULL)
+ while (p != NULL && (p->fp != fp || p->owner == NULL))
/* Not this file, try the next: */
p = p->entry.le_next;
}
@@ -180,10 +173,8 @@ do_lock(int idx, FILE *fp)
}
void
-_flockfile_debug(FILE * fp, char *fname, int lineno)
+_flockfile_debug(FILE * fp, const char *fname, int lineno)
{
- int fd, flags;
- int status;
int idx = file_idx(fp);
struct file_lock *p;
@@ -246,17 +237,16 @@ _flockfile_debug(FILE * fp, char *fname, int lineno)
}
void
-_flockfile(FILE * fp)
+flockfile(FILE * fp)
{
- _flockfile_debug(fp, __FILE__, __LINE__);
+ _flockfile_debug(fp, "?", 1);
return;
}
int
-_ftrylockfile(FILE * fp)
+ftrylockfile(FILE * fp)
{
int ret = -1;
- int status;
int idx = file_idx(fp);
struct file_lock *p;
@@ -306,9 +296,8 @@ _ftrylockfile(FILE * fp)
}
void
-_funlockfile(FILE * fp)
+funlockfile(FILE * fp)
{
- int status;
int idx = file_idx(fp);
struct file_lock *p;