summaryrefslogtreecommitdiffstats
path: root/lib/libc/db
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
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')
-rw-r--r--lib/libc/db/btree/bt_close.c2
-rw-r--r--lib/libc/db/btree/bt_open.c8
-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
-rw-r--r--lib/libc/db/mpool/mpool.c4
-rw-r--r--lib/libc/db/recno/rec_close.c4
-rw-r--r--lib/libc/db/recno/rec_open.c4
8 files changed, 27 insertions, 11 deletions
diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c
index c5e0d52..878c4c4 100644
--- a/lib/libc/db/btree/bt_close.c
+++ b/lib/libc/db/btree/bt_close.c
@@ -40,6 +40,7 @@
static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
@@ -47,6 +48,7 @@ static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
#include <db.h>
#include "btree.h"
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index d3c353f..e2e9a24 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -48,6 +48,7 @@ static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94";
* is wholly independent of the Postgres code.
*/
+#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -59,6 +60,7 @@ static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
#include <db.h>
#include "btree.h"
@@ -217,7 +219,7 @@ __bt_open(fname, flags, mode, openinfo, dflags)
if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
goto err;
- if (fstat(t->bt_fd, &sb))
+ if (_fstat(t->bt_fd, &sb))
goto err;
if (sb.st_size) {
if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
@@ -399,10 +401,10 @@ tmp()
sizeof(path), "%s/bt.XXXXXXXXXX", envtmp ? envtmp : "/tmp");
(void)sigfillset(&set);
- (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ (void)_sigprocmask(SIG_BLOCK, &set, &oset);
if ((fd = mkstemp(path)) != -1)
(void)unlink(path);
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
+ (void)_sigprocmask(SIG_SETMASK, &oset, NULL);
return(fd);
}
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);
}
diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c
index a4ab912..303d8c0 100644
--- a/lib/libc/db/mpool/mpool.c
+++ b/lib/libc/db/mpool/mpool.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -46,6 +47,7 @@ static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
#include <db.h>
@@ -76,7 +78,7 @@ mpool_open(key, fd, pagesize, maxcache)
* XXX
* We don't currently handle pipes, although we should.
*/
- if (fstat(fd, &sb))
+ if (_fstat(fd, &sb))
return (NULL);
if (!S_ISREG(sb.st_mode)) {
errno = ESPIPE;
diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c
index 25d01de..1f19bd3 100644
--- a/lib/libc/db/recno/rec_close.c
+++ b/lib/libc/db/recno/rec_close.c
@@ -37,6 +37,7 @@
static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/mman.h>
@@ -45,6 +46,7 @@ static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94";
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
+#include "un-namespace.h"
#include <db.h>
#include "recno.h"
@@ -165,7 +167,7 @@ __rec_sync(dbp, flags)
while (status == RET_SUCCESS) {
iov[0].iov_base = data.data;
iov[0].iov_len = data.size;
- if (writev(t->bt_rfd, iov, 2) != data.size + 1)
+ if (_writev(t->bt_rfd, iov, 2) != data.size + 1)
return (RET_ERROR);
status = (dbp->seq)(dbp, &key, &data, R_NEXT);
}
diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c
index eaeacc5..4098b18 100644
--- a/lib/libc/db/recno/rec_open.c
+++ b/lib/libc/db/recno/rec_open.c
@@ -40,6 +40,7 @@
static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -50,6 +51,7 @@ static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
+#include "un-namespace.h"
#include <db.h>
#include "recno.h"
@@ -146,7 +148,7 @@ slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
goto einval;
}
- if (fstat(rfd, &sb))
+ if (_fstat(rfd, &sb))
goto err;
/*
* Kluge -- we'd like to test to see if the file is too
OpenPOWER on IntegriCloud