summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:11:32 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:11:32 +0000
commitd2c8928d306861a39cc7c341e09f7e66b8f1c649 (patch)
tree4c11599bf8b3287a2c57ea361b3d9e47a09b58c4
parent43df67ad041fda13c795b8b91fc45e8b71c047cf (diff)
Fix build against libpthread
* configure.ac: Link against libpthread instead of libthreads. Explicitly link against libshouldbeinlibc. * cvs_tree.c: Include <pthread.h>, use pthread functions instead of Mach cthreads functions. * cvsfs.h: Likewise. * netfs.c: Likewise. * node.c: Likewise.
-rw-r--r--configure.ac3
-rw-r--r--cvs_tree.c19
-rw-r--r--cvsfs.h6
-rw-r--r--netfs.c54
-rw-r--r--node.c14
5 files changed, 49 insertions, 47 deletions
diff --git a/configure.ac b/configure.ac
index 1dab6582d..2c4a4a821 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,10 +16,11 @@ AM_INIT_AUTOMAKE(cvsfs, 0.2)
AC_PROG_CC
# Checks for libraries.
-AC_CHECK_LIB([threads], [rwlock_init])
+AC_CHECK_LIB([pthread], [pthread_rwlock_init])
AC_CHECK_LIB([ports], [hurd_ihash_init])
AC_CHECK_LIB([fshelp], [fshelp_touch])
AC_CHECK_LIB([iohelp], [iohelp_initialize_conch])
+AC_CHECK_LIB([shouldbeinlibc], [maptime_map])
#AC_CHECK_LIB([netfs], [netfs_startup])
# Check whether zlib compression is available
diff --git a/cvs_tree.c b/cvs_tree.c
index 8f6403425..ee390c950 100644
--- a/cvs_tree.c
+++ b/cvs_tree.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <pthread.h>
#include "cvs_connect.h"
#include "cvs_tree.h"
@@ -270,7 +271,7 @@ cvs_tree_enqueue(struct netnode *dir, const char *path)
new->fileno = next_fileno ++;
new->node = NULL;
- rwlock_init(&new->lock);
+ pthread_rwlock_init(&new->lock, NULL);
if(parent)
parent->child = new;
@@ -297,12 +298,12 @@ cvs_tree_enqueue_file(struct netnode *cwd,
{
struct revision *cached_rev;
- rwlock_writer_lock(&entry->lock);
+ pthread_rwlock_wrlock(&entry->lock);
cached_rev = entry->revision;
if(! (entry->revision = malloc(sizeof(*entry->revision))))
{
- rwlock_writer_unlock(&entry->lock);
+ pthread_rwlock_unlock(&entry->lock);
return ENOMEM; /* pray for cvsfs to survive! */
}
@@ -310,8 +311,8 @@ cvs_tree_enqueue_file(struct netnode *cwd,
entry->revision->contents = NULL;
entry->revision->next = cached_rev;
- rwlock_init(&entry->revision->lock);
- rwlock_writer_unlock(&entry->lock);
+ pthread_rwlock_init(&entry->revision->lock, NULL);
+ pthread_rwlock_unlock(&entry->lock);
return 0;
}
@@ -325,13 +326,13 @@ cvs_tree_enqueue_file(struct netnode *cwd,
/* okay, we already got a netnode for file 'filename', check whether
* revision information is up to date ...
*/
- rwlock_reader_lock(&entry->lock);
+ pthread_rwlock_rdlock(&entry->lock);
if(! strcmp(revision, entry->revision->id))
{
- rwlock_reader_unlock(&entry->lock);
+ pthread_rwlock_unlock(&entry->lock);
return 0; /* head revision id hasn't changed ... */
}
- rwlock_reader_unlock(&entry->lock);
+ pthread_rwlock_unlock(&entry->lock);
/* okay, create new revision struct */
if(cvs_tree_add_rev_struct(entry, revision))
@@ -360,7 +361,7 @@ cvs_tree_enqueue_file(struct netnode *cwd,
* to somewhere and this is the only thread to update tree info,
* we don't have to write lock to access entry->revision!
*/
- rwlock_init(&entry->lock);
+ pthread_rwlock_init(&entry->lock, NULL);
entry->revision = NULL;
if(cvs_tree_add_rev_struct(entry, revision))
diff --git a/cvsfs.h b/cvsfs.h
index 3ba85a4f0..43970a7db 100644
--- a/cvsfs.h
+++ b/cvsfs.h
@@ -14,11 +14,11 @@
#ifndef CVSFS_CONFIG_H
#define CVSFS_CONFIG_H
+#include <sys/types.h>
#include <maptime.h>
extern volatile struct mapped_time_value *cvsfs_maptime;
#include <stdio.h>
-#include <rwlock.h>
typedef struct {
@@ -92,7 +92,7 @@ struct revision {
/* locking mechanism for the revision structure, needs to be held,
* on read/write access to contents field.
*/
- struct rwlock lock;
+ pthread_rwlock_t lock;
};
@@ -133,7 +133,7 @@ struct netnode {
*
* furthermore access to node pointer must be locked.
*/
- struct rwlock lock;
+ pthread_rwlock_t lock;
};
/* pointer to root netnode */
diff --git a/netfs.c b/netfs.c
index 4355616ef..6a8009432 100644
--- a/netfs.c
+++ b/netfs.c
@@ -49,9 +49,9 @@ netfs_validate_stat (struct node *node, struct iouser *cred)
if(! node->nn->revision->contents)
{
/* head revision not available locally yet, retrieve it ... */
- rwlock_writer_lock(&node->nn->revision->lock);
+ pthread_rwlock_wrlock(&node->nn->revision->lock);
cvs_files_cache(node->nn, node->nn->revision);
- rwlock_writer_unlock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
}
if(node->nn->revision->contents)
@@ -105,7 +105,7 @@ netfs_attempt_create_file (struct iouser *user, struct node *dir,
FUNC_PROLOGUE_FMT("netfs_attempt_create_file", "name=%s", name);
*node = 0;
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
FUNC_EPILOGUE(EROFS);
}
@@ -225,7 +225,7 @@ error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
FUNC_PROLOGUE("netfs_attempt_mkfile");
*node = 0;
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
FUNC_EPILOGUE(EROFS);
}
@@ -379,14 +379,14 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
/* read-lock the real netnode - not the virtual one - what wouldn't
* make much sense.
*/
- rwlock_reader_lock(&nn->lock);
+ pthread_rwlock_rdlock(&nn->lock);
rev = dir->nn->revision;
for(; rev; rev = rev->next)
if(! strcmp(rev->id, name))
break;
- rwlock_reader_unlock(&nn->lock);
+ pthread_rwlock_unlock(&nn->lock);
if(! rev && (rev = malloc(sizeof(*rev))))
{
@@ -396,7 +396,7 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
rev->id = strdup(name);
rev->contents = NULL;
rev->next = NULL;
- rwlock_init(&rev->lock);
+ pthread_rwlock_init(&rev->lock, NULL);
if(cvs_files_hit(nn, rev))
{
@@ -408,12 +408,12 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
else
{
/* okay, went well, enqueue into revisions chain */
- rwlock_writer_lock(&nn->lock);
+ pthread_rwlock_wrlock(&nn->lock);
rev->next = nn->revision->next;
nn->revision->next = rev;
- rwlock_writer_unlock(&nn->lock);
+ pthread_rwlock_unlock(&nn->lock);
}
}
@@ -432,7 +432,7 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
err = 0; /* hey, we got it! */
spin_lock(&netfs_node_refcnt_lock);
- /* rwlock_reader_lock(&nn->lock);
+ /* pthread_rwlock_rdlock(&nn->lock);
* we don't have to lock nn->lock since it's ref cannot become
* invalid as we hold netfs_node_refcnt_lock
*/
@@ -441,7 +441,7 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
(*node)->references ++;
spin_unlock(&netfs_node_refcnt_lock);
- /* rwlock_reader_unlock(&nn->lock); */
+ /* pthread_rwlock_unlock(&nn->lock); */
if(! *node)
*node = cvsfs_make_node(nn);
@@ -453,12 +453,12 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
if(! err)
fshelp_touch(&(*node)->nn_stat, TOUCH_ATIME, cvsfs_maptime);
- mutex_unlock(&dir->lock);
+ pthread_mutex_unlock(&dir->lock);
if(err)
*node = NULL;
else
- mutex_lock(&(*node)->lock);
+ pthread_mutex_lock(&(*node)->lock);
FUNC_EPILOGUE(err);
}
@@ -613,8 +613,8 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
return EISDIR;
}
- rwlock_reader_lock(&node->nn->lock);
- rwlock_reader_lock(&node->nn->revision->lock);
+ pthread_rwlock_rdlock(&node->nn->lock);
+ pthread_rwlock_rdlock(&node->nn->revision->lock);
if(! node->nn->revision->contents)
{
@@ -626,14 +626,14 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
*/
/* oops, we need a writer lock ... */
- rwlock_reader_unlock(&node->nn->revision->lock);
- rwlock_writer_lock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
+ pthread_rwlock_wrlock(&node->nn->revision->lock);
if(cvs_files_cache(node->nn->parent ? node->nn : node->nn->child,
node->nn->revision))
{
- rwlock_writer_unlock(&node->nn->revision->lock);
- rwlock_reader_unlock(&node->nn->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->lock);
*len = 0;
return EIO;
}
@@ -641,8 +641,8 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
/* TODO consider whether there's a nicer way, so that we don't have
* to relock two times
*/
- rwlock_writer_unlock(&node->nn->revision->lock);
- rwlock_reader_lock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
+ pthread_rwlock_rdlock(&node->nn->revision->lock);
}
maxlen = node->nn->revision->length;
@@ -651,8 +651,8 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
{
/* trying to read beyond of file, cowardly refuse to do so ... */
*len = 0;
- rwlock_reader_unlock(&node->nn->revision->lock);
- rwlock_reader_unlock(&node->nn->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->lock);
return 0;
}
@@ -660,8 +660,8 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
*len = maxlen - offset;
memcpy(data, node->nn->revision->contents + offset, *len);
- rwlock_reader_unlock(&node->nn->revision->lock);
- rwlock_reader_unlock(&node->nn->lock);
+ pthread_rwlock_unlock(&node->nn->revision->lock);
+ pthread_rwlock_unlock(&node->nn->lock);
FUNC_EPILOGUE(0);
}
@@ -765,9 +765,9 @@ netfs_node_norefs (struct node *node)
/* the node will be freed, therefore our nn->node pointer will not
* be valid any longer, therefore reset it
*/
- rwlock_writer_lock(&node->nn->lock);
+ pthread_rwlock_wrlock(&node->nn->lock);
node->nn->node = NULL;
- rwlock_writer_unlock(&node->nn->lock);
+ pthread_rwlock_unlock(&node->nn->lock);
if(node->nn->revision && !node->nn->parent)
/* node is a virtual node, therefore we need to free the netnode */
diff --git a/node.c b/node.c
index a7b0908e8..658998419 100644
--- a/node.c
+++ b/node.c
@@ -35,24 +35,24 @@ cvsfs_make_node(struct netnode *nn)
{
struct node *node;
- rwlock_writer_lock(&nn->lock);
+ pthread_rwlock_wrlock(&nn->lock);
if(nn->node)
{
/* there already is a node structure, just return another reference
* to this one, instead of wasting memory for yet another one
*/
- mutex_lock(&nn->node->lock);
+ pthread_mutex_lock(&nn->node->lock);
netfs_nref(nn->node);
- mutex_unlock(&nn->node->lock);
+ pthread_mutex_unlock(&nn->node->lock);
- rwlock_writer_unlock(&nn->lock);
+ pthread_rwlock_unlock(&nn->lock);
return nn->node;
}
if(! (node = netfs_make_node(nn)))
{
- rwlock_writer_unlock(&nn->lock);
+ pthread_rwlock_unlock(&nn->lock);
return NULL;
}
@@ -124,7 +124,7 @@ cvsfs_make_node(struct netnode *nn)
node->nn_stat.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
nn->node = node;
- rwlock_writer_unlock(&nn->lock);
+ pthread_rwlock_unlock(&nn->lock);
return node;
}
@@ -148,7 +148,7 @@ cvsfs_make_virtual_node(struct netnode *nn, struct revision *rev)
if(! new_nn)
return NULL;
- rwlock_init(&new_nn->lock);
+ pthread_rwlock_init(&new_nn->lock, NULL);
new_nn->sibling = NULL;
new_nn->parent = NULL;