summaryrefslogtreecommitdiffstats
path: root/lib/libc/db/hash
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
committerdeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
commit1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch)
treed7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/db/hash
parent08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff)
downloadFreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip
FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
Diffstat (limited to 'lib/libc/db/hash')
-rw-r--r--lib/libc/db/hash/hash.c7
-rw-r--r--lib/libc/db/hash/hash_buf.c3
-rw-r--r--lib/libc/db/hash/hash_page.c6
3 files changed, 11 insertions, 5 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index dcef5df..34fe4ad 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -40,6 +40,7 @@
static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -52,6 +53,7 @@ static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
#ifdef DEBUG
#include <assert.h>
#endif
+#include "un-namespace.h"
#include <db.h>
#include "hash.h"
@@ -136,7 +138,7 @@ __hash_open(file, flags, mode, info, dflags)
/* if the .db file is empty, and we had permission to create
a new .db file, then reinitialize the database */
if ((flags & O_CREAT) &&
- fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
+ _fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
new_table = 1;
(void)_fcntl(hashp->fp, F_SETFD, 1);
@@ -562,7 +564,8 @@ hash_put(dbp, key, data, flag)
hashp = (HTAB *)dbp->internal;
if (flag && flag != R_NOOVERWRITE) {
- hashp->error = errno = EINVAL;
+ hashp->error = EINVAL;
+ errno = EINVAL;
return (ERROR);
}
if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c
index 92e1f93..afa9164 100644
--- a/lib/libc/db/hash/hash_buf.c
+++ b/lib/libc/db/hash/hash_buf.c
@@ -32,6 +32,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -56,7 +58,6 @@ static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
#include <sys/param.h>
-#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index 30445e4..dd042c8 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -56,6 +56,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
* open_temp
*/
+#include "namespace.h"
#include <sys/types.h>
#include <errno.h>
@@ -68,6 +69,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
#ifdef DEBUG
#include <assert.h>
#endif
+#include "un-namespace.h"
#include <db.h>
#include "hash.h"
@@ -866,12 +868,12 @@ open_temp(hashp)
/* Block signals; make sure file goes away at process exit. */
(void)sigfillset(&set);
- (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ (void)_sigprocmask(SIG_BLOCK, &set, &oset);
if ((hashp->fp = mkstemp(namestr)) != -1) {
(void)unlink(namestr);
(void)_fcntl(hashp->fp, F_SETFD, 1);
}
- (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
+ (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
return (hashp->fp != -1 ? 0 : -1);
}
OpenPOWER on IntegriCloud