summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:38:09 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:38:09 +0000
commitc159a059bdc152931e22f2e86553acb25c78183a (patch)
treebcef5c40fbde6952bd60e0e139bdceb52de2fa09
parent7993b3db57070ec6b37bdac13f9edf9362861f16 (diff)
Fix build against libpthread
* Makefile.am (nsmux_LDADD): Link against libpthread instead of libthreads. * nsmux.h: Include <pthread.h> instead of <cthreads.h> * lnode.h: Use pthread type instead of cthreads structure. * node.h: Likewise. * ncache.h: Likewise. * lnode.c: Use pthread functions instead of cthreads functions. * node.c: Likewise. * ncache.c: Likewise. * nsmux.c: Likewise.
-rw-r--r--Makefile.am2
-rw-r--r--lnode.c14
-rw-r--r--lnode.h2
-rw-r--r--ncache.c12
-rw-r--r--ncache.h2
-rw-r--r--node.c24
-rw-r--r--node.h2
-rw-r--r--nsmux.c58
-rw-r--r--nsmux.h2
9 files changed, 59 insertions, 59 deletions
diff --git a/Makefile.am b/Makefile.am
index 76e4fa040..91d3d9b3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,7 +52,7 @@ nsmux_LDADD = \
-lnetfs \
-lfshelp \
-liohelp \
- -lthreads \
+ -lpthread \
-lports \
-lihash \
-lshouldbeinlibc
diff --git a/lnode.c b/lnode.c
index 48d64eedc..b94629b34 100644
--- a/lnode.c
+++ b/lnode.c
@@ -61,7 +61,7 @@ void lnode_ref_remove (lnode_t * node)
}
else
/*simply unlock the node */
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
} /*lnode_ref_remove */
/*---------------------------------------------------------------------------*/
@@ -108,8 +108,8 @@ error_t lnode_create (char *name, lnode_t ** node)
node_new->references = 1;
/*Initialize the mutex and acquire a lock on this lnode */
- mutex_init (&node_new->lock);
- mutex_lock (&node_new->lock);
+ pthread_mutex_init (&node_new->lock, NULL);
+ pthread_mutex_lock (&node_new->lock);
/*Store the result in the second parameter */
*node = node_new;
@@ -239,7 +239,7 @@ error_t lnode_get (lnode_t * dir, /*search here */
if (n)
{
/*lock the node */
- mutex_lock (&n->lock);
+ pthread_mutex_lock (&n->lock);
/*increment the refcount of the found lnode */
lnode_ref_add (n);
@@ -338,7 +338,7 @@ void lnode_remove_proxy (lnode_t * node, node_t * proxy)
node_list_t p;
/*Lock the lnode */
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
/*If the first cell in the list contains a reference to `proxy` */
if (node->proxies->node == proxy)
@@ -356,7 +356,7 @@ void lnode_remove_proxy (lnode_t * node, node_t * proxy)
lnode_ref_remove (node);
/*stop right here */
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
return;
}
@@ -389,7 +389,7 @@ void lnode_remove_proxy (lnode_t * node, node_t * proxy)
/*Unlock the node */
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
return;
} /*lnode_remove_proxy */
diff --git a/lnode.h b/lnode.h
index 2a142094d..7252be27e 100644
--- a/lnode.h
+++ b/lnode.h
@@ -90,7 +90,7 @@ struct lnode
struct lnode *entries;
/*the lock, protecting this lnode */
- struct mutex lock;
+ pthread_mutex_t lock;
}; /*struct lnode */
/*---------------------------------------------------------------------------*/
typedef struct lnode lnode_t;
diff --git a/ncache.c b/ncache.c
index 80f4a43da..fe97bdbf8 100644
--- a/ncache.c
+++ b/ncache.c
@@ -59,7 +59,7 @@ void ncache_init (void)
ncache.size_current = 0;
/*Init the lock */
- mutex_init (&ncache.lock);
+ pthread_mutex_init (&ncache.lock, NULL);
} /*ncache_init */
/*---------------------------------------------------------------------------*/
@@ -90,7 +90,7 @@ error_t ncache_node_lookup (lnode_t * lnode, /*search for this */
if (!err)
{
/*lock the mutex in the looked up node */
- mutex_lock (&n->lock);
+ pthread_mutex_lock (&n->lock);
/*store the lookup result in `node` */
*node = n;
@@ -146,14 +146,14 @@ ncache_reset (void)
node_t *node;
/*Acquire a lock on the cache */
- mutex_lock (&ncache.lock);
+ pthread_mutex_lock (&ncache.lock);
/*Release the whole cache chain */
for (node = ncache.mru; node != NULL;
ncache_node_remove (node), node = ncache.mru);
/*Release the lock */
- mutex_unlock (&ncache.lock);
+ pthread_mutex_unlock (&ncache.lock);
} /*ncache_reset */
/*---------------------------------------------------------------------------*/
@@ -161,7 +161,7 @@ ncache_reset (void)
void ncache_node_add (node_t * node)
{
/*Acquire a lock on the cache */
- mutex_lock (&ncache.lock);
+ pthread_mutex_lock (&ncache.lock);
/*If there already are some nodes in the cache already */
if (ncache.size_current > 0)
@@ -216,7 +216,7 @@ void ncache_node_add (node_t * node)
} */
/*Release the lock on the cache */
- mutex_unlock (&ncache.lock);
+ pthread_mutex_unlock (&ncache.lock);
} /*ncache_node_add */
/*---------------------------------------------------------------------------*/
diff --git a/ncache.h b/ncache.h
index 618bd2dc8..ddc4e9e47 100644
--- a/ncache.h
+++ b/ncache.h
@@ -59,7 +59,7 @@ struct ncache
int size_current;
/*a lock */
- struct mutex lock;
+ pthread_mutex_t lock;
}; /*struct ncache */
/*---------------------------------------------------------------------------*/
typedef struct ncache ncache_t;
diff --git a/node.c b/node.c
index b2cefb5f6..dc820acce 100644
--- a/node.c
+++ b/node.c
@@ -46,7 +46,7 @@
/*---------------------------------------------------------------------------*/
/*--------Global Variables---------------------------------------------------*/
/*The lock protecting the underlying filesystem*/
-struct mutex ulfs_lock = MUTEX_INITIALIZER;
+pthread_mutex_t ulfs_lock = PTHREAD_MUTEX_INITIALIZER;
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
@@ -246,7 +246,7 @@ void node_destroy (node_t * np)
{
if (np->nn->lnode->node == np)
{
- mutex_lock (&np->nn->lnode->lock);
+ pthread_mutex_lock (&np->nn->lnode->lock);
/*orphan the light node */
np->nn->lnode->node = NULL;
@@ -290,7 +290,7 @@ error_t node_create_root (node_t ** root_node)
}
/*Release the lock on the lnode */
- mutex_unlock (&lnode->lock);
+ pthread_mutex_unlock (&lnode->lock);
/*Store the result in the parameter */
*root_node = node;
@@ -307,7 +307,7 @@ error_t node_init_root (node_t * node /*the root node */
error_t err = 0;
/*Acquire a lock for operations on the underlying filesystem */
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
/*Open the port to the directory specified in `dir` */
node->nn->port = file_name_lookup (dir, O_READ | O_DIRECTORY, 0);
@@ -320,7 +320,7 @@ error_t node_init_root (node_t * node /*the root node */
LOG_MSG ("node_init_root: Could not open the port for %s.", dir);
/*release the lock and stop */
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
@@ -337,7 +337,7 @@ error_t node_init_root (node_t * node /*the root node */
LOG_MSG ("node_init_root: Could not stat the root node.");
/*unlock the mutex and exit */
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
@@ -349,7 +349,7 @@ error_t node_init_root (node_t * node /*the root node */
PORT_DEALLOC (node->nn->port);
/*unlock the mutex */
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
LOG_MSG ("node_init_root: Could not strdup the directory.");
return ENOMEM;
@@ -392,7 +392,7 @@ error_t node_init_root (node_t * node /*the root node */
PORT_DEALLOC (node->nn->port);
/*unlock the mutex */
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
LOG_MSG ("node_init_root: Could not strdup the name of the root node.");
return ENOMEM;
@@ -402,7 +402,7 @@ error_t node_init_root (node_t * node /*the root node */
node->nn->lnode->name_len = strlen (p);
/*Release the lock for operations on the undelying filesystem */
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
/*Return the result of operations */
return err;
@@ -557,13 +557,13 @@ error_t node_update (node_t * node)
return err; /*return 0; actually */
/*Gain exclusive access to the root node of the filesystem */
- mutex_lock (&netfs_root_node->lock);
+ pthread_mutex_lock (&netfs_root_node->lock);
/*Construct the full path to `node` */
err = lnode_path_construct (node->nn->lnode, &path);
if (err)
{
- mutex_unlock (&netfs_root_node->lock);
+ pthread_mutex_unlock (&netfs_root_node->lock);
return err;
}
@@ -611,7 +611,7 @@ error_t node_update (node_t * node)
node->nn->flags |= FLAG_NODE_ULFS_UPTODATE;
/*Release the lock on the root node of proxy filesystem */
- mutex_unlock (&netfs_root_node->lock);
+ pthread_mutex_unlock (&netfs_root_node->lock);
/*Return the result of operations */
return err;
diff --git a/node.h b/node.h
index d930a3b69..3d4aac44f 100644
--- a/node.h
+++ b/node.h
@@ -106,7 +106,7 @@ typedef struct node_dirent node_dirent_t;
/*---------------------------------------------------------------------------*/
/*--------Global Variables---------------------------------------------------*/
/*The lock protecting the underlying filesystem*/
-extern struct mutex ulfs_lock;
+extern pthread_mutex_t ulfs_lock;
/*---------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
diff --git a/nsmux.c b/nsmux.c
index 2424a2e91..568e3661e 100644
--- a/nsmux.c
+++ b/nsmux.c
@@ -80,7 +80,7 @@ error_t
LOG_MSG ("netfs_attempt_create_file");
/*Unlock `dir` and say that we can do nothing else here */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return EOPNOTSUPP;
} /*netfs_attempt_create_file */
@@ -488,7 +488,7 @@ error_t
err = netfs_validate_stat (dir, user);
if (err)
{
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return err;
}
@@ -496,7 +496,7 @@ error_t
if (!S_ISDIR (dir->nn_stat.st_mode))
{
/*unlock the directory and stop right here */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return ENOTDIR;
}
@@ -514,7 +514,7 @@ error_t
err = netfs_validate_stat (dir, user);
if (err)
{
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return err;
}
@@ -522,7 +522,7 @@ error_t
if (!S_ISDIR (dir->nn_stat.st_mode))
{
/*unlock the directory and stop right here */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return ENOTDIR;
}
@@ -544,7 +544,7 @@ error_t
}
/*unlock the directory */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
/*stop here */
return err;
@@ -576,15 +576,15 @@ error_t
if (*node)
{
/*unlock the node */
- mutex_unlock (&(*node)->lock);
+ pthread_mutex_unlock (&(*node)->lock);
/*add the node to the cache */
ncache_node_add (*node);
}
/*Unlock the mutexes in `dir` */
- mutex_unlock (&dir->nn->lnode->lock);
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->nn->lnode->lock);
+ pthread_mutex_unlock (&dir->lock);
} /*finalize */
/*Performs a usual lookup */
@@ -689,7 +689,7 @@ error_t
if (err)
{
/*stop */
- mutex_unlock (&lnode->lock);
+ pthread_mutex_unlock (&lnode->lock);
finalize ();
return err;
}
@@ -707,13 +707,13 @@ error_t
err = lnode_path_construct (lnode, NULL);
if (err)
{
- mutex_unlock (&lnode->lock);
+ pthread_mutex_unlock (&lnode->lock);
finalize ();
return err;
}
/*Unlock the lnode */
- mutex_unlock (&lnode->lock);
+ pthread_mutex_unlock (&lnode->lock);
/*Now the node is up-to-date */
(*node)->nn->flags = FLAG_NODE_ULFS_UPTODATE;
@@ -810,13 +810,13 @@ error_t
/* Set things up in the state expected by the code from gotit: on. */
dnp = 0;
np = diruser->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
netfs_nref (np);
goto gotit;
}
dnp = diruser->po->np;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
netfs_nref (dnp); /* acquire a reference for later netfs_nput */
@@ -861,7 +861,7 @@ error_t
if (!lastcomp)
strcpy (retry_name, nextname);
error = 0;
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
goto out;
}
else if (diruser->po->root_parent != MACH_PORT_NULL)
@@ -875,7 +875,7 @@ error_t
if (!lastcomp)
strcpy (retry_name, nextname);
error = 0;
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
goto out;
}
else
@@ -908,7 +908,7 @@ error_t
np = dnp;
netfs_nref (np);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
/*`np` is a proxy node of the lower translator. We
have to create a shadow node explicitly. */
@@ -927,7 +927,7 @@ error_t
/*`np` is supposed to be unlocked by the following
code. */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
}
else
/*lookup the file in the real filesystem */
@@ -1056,7 +1056,7 @@ error_t
{
mode &= ~(S_IFMT | S_ISPARE | S_ISVTX);
mode |= S_IFREG;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
error = netfs_attempt_create_file (diruser->user, dnp,
filename, mode, &np);
@@ -1065,7 +1065,7 @@ error_t
EXCL, that's fine; otherwise, we have to retry the lookup. */
if (error == EEXIST && !excl)
{
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
goto retry_lookup;
}
@@ -1235,7 +1235,7 @@ error_t
create = 0;
}
netfs_nput (np);
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
np = 0;
}
else
@@ -1522,7 +1522,7 @@ error_t
LOG_MSG ("netfs_attempt_mkfile");
/*Unlock the directory */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
/*Operation not supported */
return EOPNOTSUPP;
@@ -1613,7 +1613,7 @@ kern_return_t
}
/*Lock the node */
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/*Check if the user is the owner of this node */
err = fshelp_isowner (&np->nn_stat, user->user);
@@ -1634,7 +1634,7 @@ kern_return_t
*cntltype = MACH_MSG_TYPE_MOVE_SEND;
/*Unlock the node */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
/*Return the result of operations */
return err;
@@ -1654,10 +1654,10 @@ netfs_shutdown (int flags)
err = fshelp_fetch_control (&node->transbox, &control);
if (!err && (control != MACH_PORT_NULL))
{
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
err = fsys_goaway (control, flags);
mach_port_deallocate (mach_task_self (), control);
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
}
else
err = 0;
@@ -1691,7 +1691,7 @@ netfs_shutdown (int flags)
}
#ifdef NOTYET
- rwlock_writer_lock (&netfs_fsys_lock);
+ pthread_rwlock_wrlock (&netfs_fsys_lock);
#endif
/* Permit all current RPC's to finish, and then suspend any new ones. */
@@ -1699,7 +1699,7 @@ netfs_shutdown (int flags)
if (err)
{
#ifdef NOTYET
- rwlock_writer_unlock (&netfs_fsys_lock);
+ pthread_rwlock_unlock (&netfs_fsys_lock);
#endif
return err;
}
@@ -1711,7 +1711,7 @@ netfs_shutdown (int flags)
ports_enable_class (netfs_protid_class);
ports_resume_class_rpcs (netfs_protid_class);
#ifdef NOTYET
- rwlock_writer_unlock (&netfs_fsys_lock);
+ pthread_rwlock_unlock (&netfs_fsys_lock);
#endif
return EBUSY;
}
diff --git a/nsmux.h b/nsmux.h
index 38cf8c810..324d7ce86 100644
--- a/nsmux.h
+++ b/nsmux.h
@@ -28,7 +28,7 @@
/*---------------------------------------------------------------------------*/
#include <stddef.h>
#include <stdlib.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>