diff options
author | jasone <jasone@FreeBSD.org> | 2000-01-27 23:07:25 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-01-27 23:07:25 +0000 |
commit | 8abe2a2d86ee5f72093b3feeabf05c9f6f963576 (patch) | |
tree | 2ebe01199c17764ebcd26435b5ce1c06ebb67ad5 /lib/libc | |
parent | 1731b249ccd9d7586d511eda8756f5c6b57b871c (diff) | |
download | FreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.zip FreeBSD-src-8abe2a2d86ee5f72093b3feeabf05c9f6f963576.tar.gz |
Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
just use _foo() <-- foo(). In the case of a libpthread that doesn't do
call conversion (such as linuxthreads and our upcoming libpthread), this
is adequate. In the case of libc_r, we still need three names, which are
now _thread_sys_foo() <-- _foo() <-- foo().
Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(),
nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo().
Remove all internal libc usage of: creat(), pause(), sleep(), system(),
tcdrain(), wait(), and waitpid().
Make thread cancellation fully POSIX-compliant.
Suggested by: deischen
Diffstat (limited to 'lib/libc')
70 files changed, 277 insertions, 274 deletions
diff --git a/lib/libc/alpha/SYS.h b/lib/libc/alpha/SYS.h index 6fddb48..778f73a 100644 --- a/lib/libc/alpha/SYS.h +++ b/lib/libc/alpha/SYS.h @@ -47,7 +47,7 @@ LLABEL(name,1): #define SYSCALL(name) \ LEAF(name,0); /* XXX # of args? */ \ - WEAK_ALIAS(__CONCAT(_libc_,name), name); \ + WEAK_ALIAS(__CONCAT(_,name), name); \ CALLSYS_ERROR(name) #define SYSCALL_NOERROR(name) \ @@ -68,7 +68,7 @@ END(name) #define PSEUDO(label,name) \ LEAF(label,0); /* XXX # of args? */ \ - WEAK_ALIAS(__CONCAT(_libc_,name), name); \ + WEAK_ALIAS(__CONCAT(_,name), name); \ CALLSYS_ERROR(name); \ RET; \ END(label); @@ -104,6 +104,7 @@ END(___CONCAT(_thread_sys_,name)) #define PSYSCALL(name) \ PLEAF(name,0); /* XXX # of args? */ \ + WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \ CALLSYS_ERROR(name) #define PRSYSCALL(name) \ @@ -114,6 +115,7 @@ PEND(name) #define PPSEUDO(label,name) \ PLEAF(label,0); /* XXX # of args? */ \ + WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \ CALLSYS_ERROR(name); \ RET; \ PEND(label) diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 5061052..3494279 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -43,18 +43,15 @@ #define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + #define RSYSCALL(x) SYSCALL(x); ret #define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret /* gas messes up offset -- although we don't currently need it, do for BCS */ @@ -76,9 +73,13 @@ */ #define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b #define PRSYSCALL(x) PSYSCALL(x); ret #define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret #else /* diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index 51f9828..3d17305 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -48,8 +48,7 @@ __creat(path, mode) mode_t mode; #endif { - return(_libc_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); + return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); } -__weak_reference(__creat, _libc_creat); -__weak_reference(_libc_creat, creat); +__weak_reference(__creat, creat); diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c index b440ee5..9401e73 100644 --- a/lib/libc/compat-43/sigcompat.c +++ b/lib/libc/compat-43/sigcompat.c @@ -109,5 +109,5 @@ sigpause(mask) sigemptyset(&set); set.__bits[0] = mask; - return (_libc_sigsuspend(&set)); + return (_sigsuspend(&set)); } diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c index fbe6a21..c5e0d52 100644 --- a/lib/libc/db/btree/bt_close.c +++ b/lib/libc/db/btree/bt_close.c @@ -105,7 +105,7 @@ __bt_close(dbp) fd = t->bt_fd; free(t); free(dbp); - return (_libc_close(fd) ? RET_ERROR : RET_SUCCESS); + return (_close(fd) ? RET_ERROR : RET_SUCCESS); } /* diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index d306993..e838f25 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -203,7 +203,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) goto einval; } - if ((t->bt_fd = _libc_open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags, mode)) < 0) goto err; } else { @@ -214,13 +214,13 @@ __bt_open(fname, flags, mode, openinfo, dflags) F_SET(t, B_INMEM); } - if (_libc_fcntl(t->bt_fd, F_SETFD, 1) == -1) + if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) goto err; if (fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { - if ((nr = _libc_read(t->bt_fd, &m, sizeof(BTMETA))) < 0) + if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0) goto err; if (nr != sizeof(BTMETA)) goto eftype; @@ -336,7 +336,7 @@ err: if (t) { if (t->bt_dbp) free(t->bt_dbp); if (t->bt_fd != -1) - (void)_libc_close(t->bt_fd); + (void)_close(t->bt_fd); free(t); } return (NULL); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 0a2f3c6..dcef5df 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -130,7 +130,7 @@ __hash_open(file, flags, mode, info, dflags) new_table = 1; } if (file) { - if ((hashp->fp = _libc_open(file, flags, mode)) == -1) + if ((hashp->fp = _open(file, flags, mode)) == -1) RETURN_ERROR(errno, error0); /* if the .db file is empty, and we had permission to create @@ -139,7 +139,7 @@ __hash_open(file, flags, mode, info, dflags) fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) new_table = 1; - (void)_libc_fcntl(hashp->fp, F_SETFD, 1); + (void)_fcntl(hashp->fp, F_SETFD, 1); } if (new_table) { if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) @@ -151,7 +151,7 @@ __hash_open(file, flags, mode, info, dflags) else hashp->hash = __default_hash; - hdrsize = _libc_read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); + hdrsize = _read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); #if BYTE_ORDER == LITTLE_ENDIAN swap_header(hashp); #endif @@ -242,7 +242,7 @@ __hash_open(file, flags, mode, info, dflags) error1: if (hashp != NULL) - (void)_libc_close(hashp->fp); + (void)_close(hashp->fp); error0: free(hashp); @@ -440,7 +440,7 @@ hdestroy(hashp) free(hashp->mapp[i]); if (hashp->fp != -1) - (void)_libc_close(hashp->fp); + (void)_close(hashp->fp); free(hashp); @@ -509,7 +509,7 @@ flush_meta(hashp) swap_header_copy(&hashp->hdr, whdrp); #endif if ((lseek(fp, (off_t)0, SEEK_SET) == -1) || - ((wsize = _libc_write(fp, whdrp, sizeof(HASHHDR))) == -1)) + ((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1)) return (-1); else if (wsize != sizeof(HASHHDR)) { diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 7a204ab..30445e4 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -539,7 +539,7 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) else page = OADDR_TO_PAGE(bucket); if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((rsize = _libc_read(fd, p, size)) == -1)) + ((rsize = _read(fd, p, size)) == -1)) return (-1); bp = (u_int16_t *)p; if (!rsize) @@ -610,7 +610,7 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap) else page = OADDR_TO_PAGE(bucket); if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((wsize = _libc_write(fd, p, size)) == -1)) + ((wsize = _write(fd, p, size)) == -1)) /* Errno is set */ return (-1); if (wsize != size) { @@ -714,8 +714,7 @@ overflow_page(hashp) #define OVMSG "HASH: Out of overflow pages. Increase page size\n" if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - - 1); + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } hashp->OVFL_POINT = splitnum; @@ -728,8 +727,7 @@ overflow_page(hashp) if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { free_page++; if (free_page >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - - 1); + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } /* @@ -753,7 +751,7 @@ overflow_page(hashp) offset++; if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } @@ -871,7 +869,7 @@ open_temp(hashp) (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((hashp->fp = mkstemp(namestr)) != -1) { (void)unlink(namestr); - (void)_libc_fcntl(hashp->fp, F_SETFD, 1); + (void)_fcntl(hashp->fp, F_SETFD, 1); } (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 00d0740..29377d3 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -207,7 +207,7 @@ mpool_get(mp, pgno, flags) off = mp->pagesize * pgno; if (lseek(mp->fd, off, SEEK_SET) != off) return (NULL); - if ((nr = _libc_read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { + if ((nr = _read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { if (nr >= 0) errno = EFTYPE; return (NULL); @@ -299,7 +299,7 @@ mpool_sync(mp) return (RET_ERROR); /* Sync the file descriptor. */ - return (_libc_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); + return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); } /* @@ -382,7 +382,7 @@ mpool_write(mp, bp) off = mp->pagesize * bp->pgno; if (lseek(mp->fd, off, SEEK_SET) != off) return (RET_ERROR); - if (_libc_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) + if (_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) return (RET_ERROR); bp->flags &= ~MPOOL_DIRTY; diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c index d1f50938..25d01de 100644 --- a/lib/libc/db/recno/rec_close.c +++ b/lib/libc/db/recno/rec_close.c @@ -86,7 +86,7 @@ __rec_close(dbp) if (fclose(t->bt_rfp)) status = RET_ERROR; } else - if (_libc_close(t->bt_rfd)) + if (_close(t->bt_rfd)) status = RET_ERROR; if (__bt_close(dbp) == RET_ERROR) @@ -152,7 +152,7 @@ __rec_sync(dbp, flags) */ status = (dbp->seq)(dbp, &key, &data, R_FIRST); while (status == RET_SUCCESS) { - if (_libc_write(t->bt_rfd, data.data, data.size) != + if (_write(t->bt_rfd, data.data, data.size) != data.size) 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 55da040..eaeacc5 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -68,7 +68,7 @@ __rec_open(fname, flags, mode, openinfo, dflags) int rfd, sverrno; /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = _libc_open(fname, flags, mode)) < 0) + if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) return (NULL); /* Create a btree in memory (backed by disk). */ @@ -215,7 +215,7 @@ err: sverrno = errno; if (dbp != NULL) (void)__bt_close(dbp); if (fname != NULL) - (void)_libc_close(rfd); + (void)_close(rfd); errno = sverrno; return (NULL); } diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 186efa3..c0569e5 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -84,10 +84,10 @@ arc4_stir(as) gettimeofday(&rdat.tv, NULL); rdat.pid = getpid(); - fd = _libc_open("/dev/urandom", O_RDONLY, 0); + fd = _open("/dev/urandom", O_RDONLY, 0); if (fd >= 0) { - (void) _libc_read(fd, rdat.rnd, sizeof(rdat.rnd)); - _libc_close(fd); + (void) _read(fd, rdat.rnd, sizeof(rdat.rnd)); + _close(fd); } /* fd < 0? Ah, what the heck. We'll just take whatever was on the * stack... */ diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c index 7f658b8..86de88d 100644 --- a/lib/libc/gen/closedir.c +++ b/lib/libc/gen/closedir.c @@ -60,5 +60,5 @@ closedir(dirp) free((void *)dirp->dd_buf); free((void *)dirp); _reclaim_telldir(dirp); - return(_libc_close(fd)); + return(_close(fd)); } diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c index 0c490e5..4f6c2f3 100644 --- a/lib/libc/gen/daemon.c +++ b/lib/libc/gen/daemon.c @@ -62,12 +62,12 @@ daemon(nochdir, noclose) if (!nochdir) (void)chdir("/"); - if (!noclose && (fd = _libc_open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); if (fd > 2) - (void)_libc_close(fd); + (void)_close(fd); } return (0); } diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 087a2a9..04bd2d2 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -249,9 +249,9 @@ execvp(name, argv) * the user may execute the wrong program. */ if (lp + ln + 2 > sizeof(buf)) { - (void)_libc_write(STDERR_FILENO, "execvp: ", 8); - (void)_libc_write(STDERR_FILENO, p, lp); - (void)_libc_write(STDERR_FILENO, ": path too long\n", + (void)_write(STDERR_FILENO, "execvp: ", 8); + (void)_write(STDERR_FILENO, p, lp); + (void)_write(STDERR_FILENO, ": path too long\n", 16); continue; } diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 2495c12..ecd79fb 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -253,12 +253,12 @@ error(err) char *p; char num[30]; - (void)_libc_write(STDERR_FILENO, "fstab: ", 7); - (void)_libc_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); - (void)_libc_write(STDERR_FILENO, ":", 1); + (void)_write(STDERR_FILENO, "fstab: ", 7); + (void)_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); + (void)_write(STDERR_FILENO, ":", 1); sprintf(num, "%d: ", LineNo); - (void)_libc_write(STDERR_FILENO, num, strlen(num)); + (void)_write(STDERR_FILENO, num, strlen(num)); p = strerror(err); - (void)_libc_write(STDERR_FILENO, p, strlen(p)); - (void)_libc_write(STDERR_FILENO, "\n", 1); + (void)_write(STDERR_FILENO, p, strlen(p)); + (void)_write(STDERR_FILENO, "\n", 1); } diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index bcab9d7..6b92a12 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -178,8 +178,7 @@ fts_open(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0)) - < 0) + if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -248,7 +247,7 @@ fts_close(sp) /* Return to original directory, save errno if necessary. */ if (!ISSET(FTS_NOCHDIR)) { saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_libc_close(sp->fts_rfd); + (void)_close(sp->fts_rfd); /* Set errno and return. */ if (saved_errno != 0) { @@ -308,7 +307,7 @@ fts_read(sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -323,7 +322,7 @@ fts_read(sp) if (instr == FTS_SKIP || (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { if (p->fts_flags & FTS_SYMFOLLOW) - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); if (sp->fts_child) { fts_lfree(sp->fts_child); sp->fts_child = NULL; @@ -398,7 +397,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _libc_open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { saved_errno = errno; - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); return (NULL); } - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR)) { if (CHDIR(sp, "..")) { SET(FTS_STOP); @@ -540,12 +539,12 @@ fts_children(sp, instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _libc_open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) return (NULL); - (void)_libc_close(fd); + (void)_close(fd); return (sp->fts_child); } @@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) return (-1); if (fstat(newfd, &sb)) { ret = -1; @@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd) bail: oerrno = errno; if (fd < 0) - (void)_libc_close(newfd); + (void)_close(newfd); errno = oerrno; return (ret); } diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index bcab9d7..6b92a12 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -178,8 +178,7 @@ fts_open(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0)) - < 0) + if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -248,7 +247,7 @@ fts_close(sp) /* Return to original directory, save errno if necessary. */ if (!ISSET(FTS_NOCHDIR)) { saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_libc_close(sp->fts_rfd); + (void)_close(sp->fts_rfd); /* Set errno and return. */ if (saved_errno != 0) { @@ -308,7 +307,7 @@ fts_read(sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -323,7 +322,7 @@ fts_read(sp) if (instr == FTS_SKIP || (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { if (p->fts_flags & FTS_SYMFOLLOW) - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); if (sp->fts_child) { fts_lfree(sp->fts_child); sp->fts_child = NULL; @@ -398,7 +397,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _libc_open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { saved_errno = errno; - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); return (NULL); } - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR)) { if (CHDIR(sp, "..")) { SET(FTS_STOP); @@ -540,12 +539,12 @@ fts_children(sp, instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _libc_open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) return (NULL); - (void)_libc_close(fd); + (void)_close(fd); return (sp->fts_child); } @@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) return (-1); if (fstat(newfd, &sb)) { ret = -1; @@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd) bail: oerrno = errno; if (fd < 0) - (void)_libc_close(newfd); + (void)_close(newfd); errno = oerrno; return (ret); } diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index aaa1372..4e41a79 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -268,7 +268,7 @@ getent(cap, len, db_array, fd, name, depth, nfield) *cap = cbuf; return (retval); } else { - fd = _libc_open(*db_p, O_RDONLY, 0); + fd = _open(*db_p, O_RDONLY, 0); if (fd < 0) continue; myfd = 1; @@ -303,10 +303,10 @@ getent(cap, len, db_array, fd, name, depth, nfield) if (bp >= b_end) { int n; - n = _libc_read(fd, buf, sizeof(buf)); + n = _read(fd, buf, sizeof(buf)); if (n <= 0) { if (myfd) - (void)_libc_close(fd); + (void)_close(fd); if (n < 0) { free(record); return (-2); @@ -345,7 +345,7 @@ getent(cap, len, db_array, fd, name, depth, nfield) if (record == NULL) { errno = ENOMEM; if (myfd) - (void)_libc_close(fd); + (void)_close(fd); return (-2); } r_end = record + newsize; @@ -435,7 +435,7 @@ tc_exp: { /* an error */ if (iret < -1) { if (myfd) - (void)_libc_close(fd); + (void)_close(fd); free(record); return (iret); } @@ -485,7 +485,7 @@ tc_exp: { if (record == NULL) { errno = ENOMEM; if (myfd) - (void)_libc_close(fd); + (void)_close(fd); free(icap); return (-2); } @@ -517,7 +517,7 @@ tc_exp: { * return capability, length and success. */ if (myfd) - (void)_libc_close(fd); + (void)_close(fd); *len = rp - record - 1; /* don't count NUL */ if (r_end > rp) if ((record = diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c index 727d58a..60e92b7 100644 --- a/lib/libc/gen/getpass.c +++ b/lib/libc/gen/getpass.c @@ -86,7 +86,7 @@ getpass(prompt) if (p < buf + _PASSWORD_LEN) *p++ = ch; *p = '\0'; - (void)_libc_write(fileno(outfp), "\n", 1); + (void)_write(fileno(outfp), "\n", 1); (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm); (void)sigprocmask(SIG_SETMASK, &oset, NULL); diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c index 4d6874b..15b5b21 100644 --- a/lib/libc/gen/lockf.c +++ b/lib/libc/gen/lockf.c @@ -75,7 +75,7 @@ lockf(filedes, function, size) break; case F_TEST: fl.l_type = F_WRLCK; - if (_libc_fcntl(filedes, F_GETLK, &fl) == -1) + if (_fcntl(filedes, F_GETLK, &fl) == -1) return (-1); if (fl.l_type == F_UNLCK || fl.l_pid == getpid()) return (0); @@ -88,5 +88,5 @@ lockf(filedes, function, size) /* NOTREACHED */ } - return (_libc_fcntl(filedes, cmd, &fl)); + return (_fcntl(filedes, cmd, &fl)); } diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 09e93aa..f459067 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -66,11 +66,11 @@ nlist(name, list) { int fd, n; - fd = _libc_open(name, O_RDONLY, 0); + fd = _open(name, O_RDONLY, 0); if (fd < 0) return (-1); n = __fdnlist(fd, list); - (void)_libc_close(fd); + (void)_close(fd); return (n); } @@ -255,7 +255,7 @@ __elf_fdnlist(fd, list) /* Make sure obj is OK */ if (lseek(fd, (off_t)0, SEEK_SET) == -1 || - _libc_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) || + _read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) || !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) return (-1); @@ -339,7 +339,7 @@ __elf_fdnlist(fd, list) while (symsize > 0 && nent > 0) { cc = MIN(symsize, sizeof(sbuf)); - if (_libc_read(fd, sbuf, cc) != cc) + if (_read(fd, sbuf, cc) != cc) break; symsize -= cc; for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) { diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 077805d..d94b9af 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -80,7 +80,7 @@ __opendir2(name, flags) errno = ENOTDIR; return (NULL); } - if ((fd = _libc_open(name, O_RDONLY | O_NONBLOCK)) == -1) + if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1) return (NULL); dirp = NULL; if (fstat(fd, &statb) != 0) @@ -89,7 +89,7 @@ __opendir2(name, flags) errno = ENOTDIR; goto fail; } - if (_libc_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || + if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || (dirp = malloc(sizeof(DIR))) == NULL) goto fail; @@ -163,8 +163,8 @@ __opendir2(name, flags) * which has also been read -- see fts.c. */ if (flags & DTF_REWIND) { - (void)_libc_close(fd); - if ((fd = _libc_open(name, O_RDONLY)) == -1) { + (void)_close(fd); + if ((fd = _open(name, O_RDONLY)) == -1) { saved_errno = errno; free(buf); free(dirp); @@ -270,7 +270,7 @@ __opendir2(name, flags) fail: saved_errno = errno; free(dirp); - (void)_libc_close(fd); + (void)_close(fd); errno = saved_errno; return (NULL); } diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c index b1e976e..3327c96 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -49,5 +49,4 @@ __pause() return sigpause(sigblock(0L)); } -__weak_reference(__pause, _libc_pause); -__weak_reference(_libc_pause, pause); +__weak_reference(__pause, pause); diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index c744efd..7939b8f 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -85,8 +85,8 @@ popen(command, type) return (NULL); if ((cur = malloc(sizeof(struct pid))) == NULL) { - (void)_libc_close(pdes[0]); - (void)_libc_close(pdes[1]); + (void)_close(pdes[0]); + (void)_close(pdes[1]); return (NULL); } @@ -97,8 +97,8 @@ popen(command, type) switch (pid = vfork()) { case -1: /* Error. */ - (void)_libc_close(pdes[0]); - (void)_libc_close(pdes[1]); + (void)_close(pdes[0]); + (void)_close(pdes[1]); free(cur); return (NULL); /* NOTREACHED */ @@ -112,10 +112,10 @@ popen(command, type) * the compiler is free to corrupt all the local * variables. */ - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); if (pdes[1] != STDOUT_FILENO) { (void)dup2(pdes[1], STDOUT_FILENO); - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); if (twoway) (void)dup2(STDOUT_FILENO, STDIN_FILENO); } else if (twoway && (pdes[1] != STDIN_FILENO)) @@ -123,12 +123,12 @@ popen(command, type) } else { if (pdes[0] != STDIN_FILENO) { (void)dup2(pdes[0], STDIN_FILENO); - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); } - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); } for (p = pidlist; p; p = p->next) { - (void)_libc_close(fileno(p->fp)); + (void)_close(fileno(p->fp)); } execve(_PATH_BSHELL, argv, environ); _exit(127); @@ -138,10 +138,10 @@ popen(command, type) /* Parent; assume fdopen can't fail. */ if (*type == 'r') { iop = fdopen(pdes[0], type); - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); } else { iop = fdopen(pdes[1], type); - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); } /* Link into list of file descriptors. */ @@ -177,7 +177,7 @@ pclose(iop) (void)fclose(iop); do { - pid = _libc_waitpid(cur->pid, &pstat, 0); + pid = _wait4(cur->pid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); /* Remove the entry from the linked list. */ diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c index 704a3ae..7c25476 100644 --- a/lib/libc/gen/psignal.c +++ b/lib/libc/gen/psignal.c @@ -57,9 +57,9 @@ psignal(sig, s) else c = "Unknown signal"; if (s != NULL && *s != '\0') { - (void)_libc_write(STDERR_FILENO, s, strlen(s)); - (void)_libc_write(STDERR_FILENO, ": ", 2); + (void)_write(STDERR_FILENO, s, strlen(s)); + (void)_write(STDERR_FILENO, ": ", 2); } - (void)_libc_write(STDERR_FILENO, c, strlen(c)); - (void)_libc_write(STDERR_FILENO, "\n", 1); + (void)_write(STDERR_FILENO, c, strlen(c)); + (void)_write(STDERR_FILENO, "\n", 1); } diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c index e1fa498..e9b5d45 100644 --- a/lib/libc/gen/setjmperr.c +++ b/lib/libc/gen/setjmperr.c @@ -51,5 +51,5 @@ void longjmperror() { #define ERRMSG "longjmp botch.\n" - (void)_libc_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); + (void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); } diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index 4a35cf0..2508e9a 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -60,7 +60,7 @@ __sleep(seconds) time_to_sleep.tv_sec = seconds; time_to_sleep.tv_nsec = 0; - if (_libc_nanosleep(&time_to_sleep, &time_remaining) != -1) + if (_nanosleep(&time_to_sleep, &time_remaining) != -1) return (0); if (errno != EINTR) return (seconds); /* best guess */ @@ -68,5 +68,4 @@ __sleep(seconds) (time_remaining.tv_nsec != 0)); /* round up */ } -__weak_reference(__sleep, _libc_sleep); -__weak_reference(_libc_sleep, sleep); +__weak_reference(__sleep, sleep); diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 2a53432..18d00d7 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -260,7 +260,7 @@ vsyslog(pri, fmt, ap) * is the one from the syslogd failure. */ if (LogStat & LOG_CONS && - (fd = _libc_open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { + (fd = _open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { struct iovec iov[2]; register struct iovec *v = iov; @@ -271,7 +271,7 @@ vsyslog(pri, fmt, ap) v->iov_base = "\r\n"; v->iov_len = 2; (void)writev(fd, iov, 2); - (void)_libc_close(fd); + (void)_close(fd); } } static void @@ -283,7 +283,7 @@ disconnectlog() * system services. */ if (LogFile != -1) { - _libc_close(LogFile); + _close(LogFile); LogFile = -1; } connected = 0; /* retry connect */ @@ -297,7 +297,7 @@ connectlog() if (LogFile == -1) { if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return; - (void)_libc_fcntl(LogFile, F_SETFD, 1); + (void)_fcntl(LogFile, F_SETFD, 1); } if (LogFile != -1 && !connected) { SyslogAddr.sun_len = sizeof(SyslogAddr); @@ -320,7 +320,7 @@ connectlog() } if (!connected) { - (void)_libc_close(LogFile); + (void)_close(LogFile); LogFile = -1; } } @@ -346,7 +346,7 @@ openlog(ident, logstat, logfac) void closelog() { - (void)_libc_close(LogFile); + (void)_close(LogFile); LogFile = -1; connected = 0; } diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c index 70ac8f0..466827e 100644 --- a/lib/libc/gen/termios.c +++ b/lib/libc/gen/termios.c @@ -195,8 +195,7 @@ __tcdrain(fd) return (ioctl(fd, TIOCDRAIN, 0)); } -__weak_reference(__tcdrain, _libc_tcdrain); -__weak_reference(_libc_tcdrain, tcdrain); +__weak_reference(__tcdrain, tcdrain); int tcflush(fd, which) @@ -238,8 +237,7 @@ tcflow(fd, action) if (tcgetattr(fd, &term) == -1) return (-1); c = term.c_cc[action == TCIOFF ? VSTOP : VSTART]; - if (c != _POSIX_VDISABLE && _libc_write(fd, &c, sizeof(c)) == - -1) + if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1) return (-1); return (0); default: diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 05b6927..651edf9 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -50,5 +50,5 @@ usleep(useconds) time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; time_to_sleep.tv_sec = useconds / 1000000; - return (_libc_nanosleep(&time_to_sleep, NULL)); + return (_nanosleep(&time_to_sleep, NULL)); } diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 21f4d11..2f9ca6e 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -49,5 +49,4 @@ __wait(istat) return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); } -__weak_reference(__wait, _libc_wait); -__weak_reference(_libc_wait, wait); +__weak_reference(__wait, wait); diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index 14a5e1a..3f679a7 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -55,5 +55,4 @@ __waitpid(pid, istat, options) return (wait4(pid, istat, options, (struct rusage *)0)); } -__weak_reference(__waitpid, _libc_waitpid); -__weak_reference(_libc_waitpid, waitpid); +__weak_reference(__waitpid, waitpid); diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 938cd02..6bf3d5b 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -62,7 +62,7 @@ static int s_scale; /* see profil(2) where this is describe (incorrectly) */ #define SCALE_1_TO_1 0x10000L -#define ERR(s) _libc_write(2, s, sizeof(s)) +#define ERR(s) _write(2, s, sizeof(s)) void moncontrol __P((int)); static int hertz __P((void)); @@ -172,20 +172,20 @@ _mcleanup() moncontrol(0); snprintf(outname,sizeof(outname),"%s.gmon",__progname); - fd = _libc_open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); + fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) { warnx("_mcleanup: %s - %s",outname,strerror(errno)); return; } #ifdef DEBUG - log = _libc_open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); + log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); if (log < 0) { perror("_mcleanup: gmon.log"); return; } len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n", p->kcount, p->kcountsize); - _libc_write(log, buf, len); + _write(log, buf, len); #endif hdr = (struct gmonhdr *)&gmonhdr; hdr->lpc = p->lowpc; @@ -193,8 +193,8 @@ _mcleanup() hdr->ncnt = p->kcountsize + sizeof(gmonhdr); hdr->version = GMONVERSION; hdr->profrate = clockinfo.profhz; - _libc_write(fd, (char *)hdr, sizeof *hdr); - _libc_write(fd, p->kcount, p->kcountsize); + _write(fd, (char *)hdr, sizeof *hdr); + _write(fd, p->kcount, p->kcountsize); endfrom = p->fromssize / sizeof(*p->froms); for (fromindex = 0; fromindex < endfrom; fromindex++) { if (p->froms[fromindex] == 0) @@ -209,15 +209,15 @@ _mcleanup() "[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" , frompc, p->tos[toindex].selfpc, p->tos[toindex].count); - _libc_write(log, buf, len); + _write(log, buf, len); #endif rawarc.raw_frompc = frompc; rawarc.raw_selfpc = p->tos[toindex].selfpc; rawarc.raw_count = p->tos[toindex].count; - _libc_write(fd, &rawarc, sizeof rawarc); + _write(fd, &rawarc, sizeof rawarc); } } - _libc_close(fd); + _close(fd); } /* diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h index 5061052..3494279 100644 --- a/lib/libc/i386/SYS.h +++ b/lib/libc/i386/SYS.h @@ -43,18 +43,15 @@ #define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + #define RSYSCALL(x) SYSCALL(x); ret #define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret /* gas messes up offset -- although we don't currently need it, do for BCS */ @@ -76,9 +73,13 @@ */ #define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b #define PRSYSCALL(x) PSYSCALL(x); ret #define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret #else /* diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index f726898..373019c 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -177,14 +177,14 @@ __collate_err(int ex, const char *f) int serrno = errno; s = __progname; - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, ": ", 2); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, ": ", 2); s = f; - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, ": ", 2); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, ": ", 2); s = strerror(serrno); - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, "\n", 1); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, "\n", 1); exit(ex); } diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 414898e..9f0a47a 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -578,7 +578,7 @@ explore_null(pai, hostname, servname, res) s = socket(pai->ai_family, SOCK_DGRAM, 0); if (s < 0) return 0; - _libc_close(s); + _close(s); afd = find_afd(pai->ai_family); if (afd == NULL) return 0; diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index e3ddf3e..3f39d03 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -257,7 +257,7 @@ _ghbyname(const char *name, int af, int flags, int *errp) * (or apropriate interval), * because addresses will be dynamically assigned or deleted. */ - _libc_close(s); + _close(s); } for (i = 0; i < MAXHOSTCONF; i++) { @@ -1184,21 +1184,21 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) (char *)&filter, sizeof(filter)); cc = sendmsg(s, &msg, 0); if (cc < 0) { - _libc_close(s); + _close(s); return NULL; } FD_SET(s, &s_fds); for (;;) { fds = s_fds; if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) { - _libc_close(s); + _close(s); return NULL; } len = sizeof(sin6); cc = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin6, &len); if (cc <= 0) { - _libc_close(s); + _close(s); return NULL; } if (cc < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) @@ -1209,7 +1209,7 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) if (fr->icmp6_fqdn_type == ICMP6_FQDN_REPLY) break; } - _libc_close(s); + _close(s); if (fr->icmp6_fqdn_cookie[1] != 0) { /* rfc1788 type */ name = buf + sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) + 4; diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 96d5bab..1448f14 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -136,10 +136,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) freeaddrinfo(res); return (-1); } - _libc_fcntl(s, F_SETOWN, pid); + _fcntl(s, F_SETOWN, pid); if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) break; - (void)_libc_close(s); + (void)_close(s); if (errno == EADDRINUSE) { lport--; continue; @@ -166,7 +166,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) continue; } if (refused && timo <= 16) { - (void)_libc_sleep(timo); + struct timespec time_to_sleep, time_remaining; + + time_to_sleep.tv_sec = timo; + time_to_sleep.tv_nsec = 0; + (void)_nanosleep(&time_to_sleep, &time_remaining); + timo *= 2; ai = res; refused = 0; @@ -179,7 +184,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) } lport--; if (fd2p == 0) { - _libc_write(s, "", 1); + _write(s, "", 1); lport = 0; } else { char num[8]; @@ -191,17 +196,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) goto bad; listen(s2, 1); (void)snprintf(num, sizeof(num), "%d", lport); - if (_libc_write(s, num, strlen(num)+1) != strlen(num)+1) { + if (_write(s, num, strlen(num)+1) != strlen(num)+1) { (void)fprintf(stderr, "rcmd: write (setting up stderr): %s\n", strerror(errno)); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } nfds = max(s, s2)+1; if(nfds > FD_SETSIZE) { fprintf(stderr, "rcmd: too many files\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } again: @@ -217,7 +222,7 @@ again: else (void)fprintf(stderr, "select: protocol failure in circuit setup\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); @@ -239,10 +244,10 @@ again: * down and check for the real auxiliary channel to connect. */ if (aport == 20) { - _libc_close(s3); + _close(s3); goto again; } - (void)_libc_close(s2); + (void)_close(s2); if (s3 < 0) { (void)fprintf(stderr, "rcmd: accept: %s\n", strerror(errno)); @@ -256,17 +261,17 @@ again: goto bad2; } } - (void)_libc_write(s, locuser, strlen(locuser)+1); - (void)_libc_write(s, remuser, strlen(remuser)+1); - (void)_libc_write(s, cmd, strlen(cmd)+1); - if (_libc_read(s, &c, 1) != 1) { + (void)_write(s, locuser, strlen(locuser)+1); + (void)_write(s, remuser, strlen(remuser)+1); + (void)_write(s, cmd, strlen(cmd)+1); + if (_read(s, &c, 1) != 1) { (void)fprintf(stderr, "rcmd: %s: %s\n", *ahost, strerror(errno)); goto bad2; } if (c != 0) { - while (_libc_read(s, &c, 1) == 1) { - (void)_libc_write(STDERR_FILENO, &c, 1); + while (_read(s, &c, 1) == 1) { + (void)_write(STDERR_FILENO, &c, 1); if (c == '\n') break; } @@ -277,9 +282,9 @@ again: return (s); bad2: if (lport) - (void)_libc_close(*fd2p); + (void)_close(*fd2p); bad: - (void)_libc_close(s); + (void)_close(s); sigsetmask(oldmask); freeaddrinfo(res); return (-1); @@ -328,13 +333,13 @@ rresvport_af(alport, family) if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return (s); if (errno != EADDRINUSE) { - (void)_libc_close(s); + (void)_close(s); return (-1); } #endif *sport = 0; if (bindresvport_sa(s, (struct sockaddr *)&ss) == -1) { - (void)_libc_close(s); + (void)_close(s); return (-1); } *alport = (int)ntohs(*sport); diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index b57b8db..68a7c60 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -428,7 +428,7 @@ res_send(buf, buflen, ans, anssiz) read_len: cp = ans; len = INT16SZ; - while ((n = _libc_read(s, (char *)cp, (int)len)) > 0) { + while ((n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) <= 0) break; @@ -476,7 +476,7 @@ read_len: } cp = ans; while (len != 0 && - (n = _libc_read(s, (char *)cp, (int)len)) > 0) { + (n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } @@ -499,7 +499,7 @@ read_len: n = (len > sizeof(junk) ? sizeof(junk) : len); - if ((n = _libc_read(s, junk, n)) > 0) + if ((n = _read(s, junk, n)) > 0) len -= n; else break; @@ -608,7 +608,7 @@ read_len: if (s1 < 0) goto bad_dg_sock; (void)dup2(s1, s); - (void)_libc_close(s1); + (void)_close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n")) #endif /* CAN_RECONNECT */ @@ -893,7 +893,7 @@ void res_close() { if (s >= 0) { - (void)_libc_close(s); + (void)_close(s); s = -1; connected = 0; vc = 0; diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index bdb089a..f1355df 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -285,7 +285,7 @@ nl_catd catd; return -1; } - if (cat->loadType != MCLoadAll) _libc_close(cat->fd); + if (cat->loadType != MCLoadAll) _close(cat->fd); for (i = 0; i < cat->numSets; ++i) { set = cat->sets + i; if (!set->invalid) { @@ -321,14 +321,14 @@ __const char *catpath; if (!cat) return(NLERR); cat->loadType = MCLoadBySet; - if ((cat->fd = _libc_open(catpath, O_RDONLY)) < 0) { + if ((cat->fd = _open(catpath, O_RDONLY)) < 0) { free(cat); return(NLERR); } - (void)_libc_fcntl(cat->fd, F_SETFD, FD_CLOEXEC); + (void)_fcntl(cat->fd, F_SETFD, FD_CLOEXEC); - if (_libc_read(cat->fd, &header, sizeof(header)) != sizeof(header)) + if (_read(cat->fd, &header, sizeof(header)) != sizeof(header)) CORRUPT(); if (strncmp(header.magic, MCMagic, MCMagicLen) != 0) CORRUPT(); @@ -369,7 +369,7 @@ __const char *catpath; /* read in the set header */ set = cat->sets + i; - if (_libc_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) { + if (_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) { for (j = 0; j < i; j++) { set = cat->sets + j; if (!set->invalid) { @@ -408,7 +408,7 @@ __const char *catpath; nextSet = set->nextSet; } if (cat->loadType == MCLoadAll) { - _libc_close(cat->fd); + _close(cat->fd); cat->fd = -1; } return((nl_catd) cat); @@ -424,7 +424,7 @@ MCSetT *set; /* Get the data */ if (lseek(cat->fd, set->data.off, 0) == -1) return(0); if ((set->data.str = malloc(set->dataLen)) == NULL) return(-1); - if (_libc_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) { + if (_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) { free(set->data.str); return(0); } @@ -438,7 +438,7 @@ MCSetT *set; for (i = 0; i < set->numMsgs; ++i) { msg = set->u.msgs + i; - if (_libc_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) { + if (_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) { free(set->u.msgs); free(set->data.str); return(0); } if (msg->invalid) { diff --git a/lib/libc/rpc/auth_time.c b/lib/libc/rpc/auth_time.c index 47f5212..836a69f 100644 --- a/lib/libc/rpc/auth_time.c +++ b/lib/libc/rpc/auth_time.c @@ -437,7 +437,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) msg("alarm caught it, must be unreachable."); goto error; } - res = _libc_read(s, (char *)&thetime, sizeof(thetime)); + res = _read(s, (char *)&thetime, sizeof(thetime)); if (res != sizeof(thetime)) { if (saw_alarm) msg("timed out TCP call."); @@ -449,7 +449,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) time_valid = 1; } save = errno; - (void)_libc_close(s); + (void)_close(s); errno = save; s = RPC_ANYSOCK; @@ -468,7 +468,7 @@ error: */ if (s != RPC_ANYSOCK) - (void)_libc_close(s); + (void)_close(s); if (clnt != NULL) clnt_destroy(clnt); diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index d9623a9..897eab5 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -86,7 +86,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) } else { crp->valid = 0; if (crp->socket != -1) - (void)_libc_close(crp->socket); + (void)_close(crp->socket); crp->socket = RPC_ANYSOCK; if (crp->client) { clnt_destroy(crp->client); diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index 6cddb7b..1889694 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -167,7 +167,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; if (*sockp != -1) - (void)_libc_close(*sockp); + (void)_close(*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -200,7 +200,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { - (void)_libc_close(*sockp); + (void)_close(*sockp); } goto fooy; } @@ -474,7 +474,7 @@ clnttcp_destroy(h) (struct ct_data *) h->cl_private; if (ct->ct_closeit) { - (void)_libc_close(ct->ct_sock); + (void)_close(ct->ct_sock); } XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); @@ -544,7 +544,7 @@ readtcp(ct, buf, len) } break; } - switch (len = _libc_read(ct->ct_sock, buf, len)) { + switch (len = _read(ct->ct_sock, buf, len)) { case 0: /* premature eof */ @@ -570,7 +570,7 @@ writetcp(ct, buf, len) register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = _libc_write(ct->ct_sock, buf, cnt)) == -1) { + if ((i = _write(ct->ct_sock, buf, cnt)) == -1) { ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTSEND; return (-1); diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index f7f7b50..3dc7710 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -559,7 +559,7 @@ clntudp_destroy(cl) register struct cu_data *cu = (struct cu_data *)cl->cl_private; if (cu->cu_closeit) { - (void)_libc_close(cu->cu_sock); + (void)_close(cu->cu_sock); } XDR_DESTROY(&(cu->cu_outxdrs)); mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); diff --git a/lib/libc/rpc/clnt_unix.c b/lib/libc/rpc/clnt_unix.c index 5deb8b0..3b28bf8 100644 --- a/lib/libc/rpc/clnt_unix.c +++ b/lib/libc/rpc/clnt_unix.c @@ -158,7 +158,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; if (*sockp != -1) - (void)_libc_close(*sockp); + (void)_close(*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -191,7 +191,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { - (void)_libc_close(*sockp); + (void)_close(*sockp); } goto fooy; } @@ -465,7 +465,7 @@ clntunix_destroy(h) (struct ct_data *) h->cl_private; if (ct->ct_closeit) { - (void)_libc_close(ct->ct_sock); + (void)_close(ct->ct_sock); } XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c index 2c129a4..05fae48 100644 --- a/lib/libc/rpc/get_myaddress.c +++ b/lib/libc/rpc/get_myaddress.c @@ -73,7 +73,7 @@ get_myaddress(addr) ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { - _libc_close(s); + _close(s); return(-1); } again: @@ -83,7 +83,7 @@ again: while (ifr < end) { ifreq = *ifr; if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - _libc_close(s); + _close(s); return(-1); } if (((ifreq.ifr_flags & IFF_UP) && @@ -107,6 +107,6 @@ again: loopback = 1; goto again; } - (void)_libc_close(s); + (void)_close(s); return (gotit ? 0 : -1); } diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c index bb0d06b..703e038 100644 --- a/lib/libc/rpc/key_call.c +++ b/lib/libc/rpc/key_call.c @@ -369,7 +369,7 @@ int vers; (void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT, (char *)&wait_time); if (clnt_control(kcp->client, CLGET_FD, (char *)&fd)) - _libc_fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ + _fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ return (kcp->client); } diff --git a/lib/libc/rpc/pmap_clnt.c b/lib/libc/rpc/pmap_clnt.c index f306a78..540187b 100644 --- a/lib/libc/rpc/pmap_clnt.c +++ b/lib/libc/rpc/pmap_clnt.c @@ -102,7 +102,7 @@ pmap_set(program, version, protocol, port) } CLNT_DESTROY(client); if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); return (rslt); } @@ -144,6 +144,6 @@ pmap_unset(program, version) tottimeout); CLNT_DESTROY(client); if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); return (rslt); } diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index 06dabfe..777877b 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -80,7 +80,7 @@ pmap_getmaps(address) CLNT_DESTROY(client); } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); address->sin_port = 0; return (head); } diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index 7e4c38b..2d6f5ac 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -85,7 +85,7 @@ pmap_getport(address, program, version, protocol) CLNT_DESTROY(client); } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); address->sin_port = 0; return (port); } diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index da63488..55ddef9 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -98,7 +98,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt stat = RPC_FAILED; } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); addr->sin_port = 0; return (stat); } @@ -408,7 +408,7 @@ done_broad: if (fds != &readfds) free(fds); if (sock >= 0) - (void)_libc_close(sock); + (void)_close(sock); AUTH_DESTROY(unix_auth); return (stat); } diff --git a/lib/libc/rpc/rtime.c b/lib/libc/rpc/rtime.c index 25b11ca..0aaf7c0 100644 --- a/lib/libc/rpc/rtime.c +++ b/lib/libc/rpc/rtime.c @@ -129,7 +129,7 @@ rtime(addrp, timep, timeout) do_close(s); return(-1); } - res = _libc_read(s, (char *)&thetime, sizeof(thetime)); + res = _read(s, (char *)&thetime, sizeof(thetime)); do_close(s); if (res < 0) { return(-1); @@ -152,6 +152,6 @@ do_close(s) int save; save = errno; - (void)_libc_close(s); + (void)_close(s); errno = save; } diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index da34518..3e14010 100644 --- a/lib/libc/rpc/svc_tcp.c +++ b/lib/libc/rpc/svc_tcp.c @@ -145,7 +145,7 @@ svctcp_create(sock, sendsize, recvsize) if (ioctl(sock, FIONBIO, &on) < 0) { perror("svc_tcp.c - cannot turn on non-blocking mode"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } memset(&addr, 0, sizeof (addr)); @@ -159,7 +159,7 @@ svctcp_create(sock, sendsize, recvsize) (listen(sock, 2) != 0)) { perror("svctcp_.c - cannot getsockname or listen"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); @@ -257,7 +257,7 @@ rendezvous_request(xprt) * Guard against FTP bounce attacks. */ if (addr.sin_port == htons(20)) { - _libc_close(sock); + _close(sock); return (FALSE); } /* @@ -265,7 +265,7 @@ rendezvous_request(xprt) */ off = 0; if (ioctl(sock, FIONBIO, &off) < 0) { - _libc_close(sock); + _close(sock); return (FALSE); } /* @@ -291,7 +291,7 @@ svctcp_destroy(xprt) register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; @@ -376,7 +376,7 @@ readtcp(xprt, buf, len) } } } while (!FD_ISSET(sock, fds)); - if ((len = _libc_read(sock, buf, len)) > 0) { + if ((len = _read(sock, buf, len)) > 0) { if (fds != NULL) free(fds); return (len); @@ -401,7 +401,7 @@ writetcp(xprt, buf, len) register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = _libc_write(xprt->xp_sock, buf, cnt)) < 0) { + if ((i = _write(xprt->xp_sock, buf, cnt)) < 0) { ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; return (-1); diff --git a/lib/libc/rpc/svc_udp.c b/lib/libc/rpc/svc_udp.c index c30d224..9849d53 100644 --- a/lib/libc/rpc/svc_udp.c +++ b/lib/libc/rpc/svc_udp.c @@ -123,7 +123,7 @@ svcudp_bufcreate(sock, sendsz, recvsz) if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { perror("svcudp_create - cannot getsockname"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); @@ -259,7 +259,7 @@ svcudp_destroy(xprt) register struct svcudp_data *su = su_data(xprt); xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); XDR_DESTROY(&(su->su_xdrs)); mem_free(rpc_buffer(xprt), su->su_iosz); mem_free((caddr_t)su, sizeof(struct svcudp_data)); diff --git a/lib/libc/rpc/svc_unix.c b/lib/libc/rpc/svc_unix.c index 63a3bad..dc680d0 100644 --- a/lib/libc/rpc/svc_unix.c +++ b/lib/libc/rpc/svc_unix.c @@ -213,7 +213,7 @@ svcunix_create(sock, sendsize, recvsize, path) (listen(sock, 2) != 0)) { perror("svc_unix.c - cannot getsockname or listen"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } r = (struct unix_rendezvous *)mem_alloc(sizeof(*r)); @@ -333,7 +333,7 @@ svcunix_destroy(xprt) register struct unix_conn *cd = (struct unix_conn *)xprt->xp_p1; xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 1c56a9d..44341b3 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -63,7 +63,7 @@ fdopen(fd, mode) return (NULL); /* Make sure the mode the user wants is a subset of the actual mode. */ - if ((fdflags = _libc_fcntl(fd, F_GETFL, 0)) < 0) + if ((fdflags = _fcntl(fd, F_GETFL, 0)) < 0) return (NULL); tmp = fdflags & O_ACCMODE; if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) { diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index d41122c..1ef6bda 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -60,7 +60,7 @@ fopen(file, mode) return (NULL); if ((fp = __sfp()) == NULL) return (NULL); - if ((f = _libc_open(file, oflags, DEFFILEMODE)) < 0) { + if ((f = _open(file, oflags, DEFFILEMODE)) < 0) { fp->_flags = 0; /* release */ return (NULL); } diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c index 39399f3..f6fa754 100644 --- a/lib/libc/stdio/freopen.c +++ b/lib/libc/stdio/freopen.c @@ -100,13 +100,13 @@ freopen(file, mode, fp) } /* Get a new descriptor to refer to the new file. */ - f = _libc_open(file, oflags, DEFFILEMODE); + f = _open(file, oflags, DEFFILEMODE); if (f < 0 && isopen) { /* If out of fd's close the old one and try again. */ if (errno == ENFILE || errno == EMFILE) { (void) (*fp->_close)(fp->_cookie); isopen = 0; - f = _libc_open(file, oflags, DEFFILEMODE); + f = _open(file, oflags, DEFFILEMODE); } } sverrno = errno; @@ -147,7 +147,7 @@ freopen(file, mode, fp) */ if (wantfd >= 0 && f != wantfd) { if (dup2(f, wantfd) >= 0) { - (void)_libc_close(f); + (void)_close(f); f = wantfd; } } diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c index 42c5da2..1f9be80 100644 --- a/lib/libc/stdio/gets.c +++ b/lib/libc/stdio/gets.c @@ -59,7 +59,7 @@ gets(buf) "warning: this program uses gets(), which is unsafe.\n"; if (!warned) { - (void) _libc_write(STDERR_FILENO, w, sizeof(w) - 1); + (void) _write(STDERR_FILENO, w, sizeof(w) - 1); warned = 1; } for (s = buf; (c = getchar()) != '\n';) diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index 98f0170..13e15d4 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -163,7 +163,7 @@ _gettemp(path, doopen, domkdir, slen) for (;;) { if (doopen) { if ((*doopen = - _libc_open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) return(1); if (errno != EEXIST) return(0); diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 777f336..b8a3f47 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -60,7 +60,7 @@ __sread(cookie, buf, n) register FILE *fp = cookie; register int ret; - ret = _libc_read(fp->_file, buf, (size_t)n); + ret = _read(fp->_file, buf, (size_t)n); /* if the read succeeded, update the current offset */ if (ret >= 0) fp->_offset += ret; @@ -80,7 +80,7 @@ __swrite(cookie, buf, n) if (fp->_flags & __SAPP) (void) lseek(fp->_file, (off_t)0, SEEK_END); fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */ - return (_libc_write(fp->_file, buf, (size_t)n)); + return (_write(fp->_file, buf, (size_t)n)); } fpos_t @@ -107,5 +107,5 @@ __sclose(cookie) void *cookie; { - return (_libc_close(((FILE *)cookie)->_file)); + return (_close(((FILE *)cookie)->_file)); } diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c index d4beac6..a0162c2 100644 --- a/lib/libc/stdio/tmpfile.c +++ b/lib/libc/stdio/tmpfile.c @@ -74,7 +74,7 @@ tmpfile() if ((fp = fdopen(fd, "w+")) == NULL) { sverrno = errno; - (void)_libc_close(fd); + (void)_close(fd); errno = sverrno; return (NULL); } diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index bf41790..ac0dd48 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -72,7 +72,7 @@ static int fdzero; # define MMAP_FD fdzero # define INIT_MMAP() \ - { if ((fdzero = _libc_open("/dev/zero", O_RDWR, 0000)) == -1) \ + { if ((fdzero = _open("/dev/zero", O_RDWR, 0000)) == -1) \ wrterror("open of /dev/zero"); } # define MADV_FREE MADV_DONTNEED #endif /* __sparc__ */ @@ -275,10 +275,10 @@ static void wrterror(char *p) { char *q = " error: "; - _libc_write(STDERR_FILENO, __progname, strlen(__progname)); - _libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func)); - _libc_write(STDERR_FILENO, q, strlen(q)); - _libc_write(STDERR_FILENO, p, strlen(p)); + _write(STDERR_FILENO, __progname, strlen(__progname)); + _write(STDERR_FILENO, malloc_func, strlen(malloc_func)); + _write(STDERR_FILENO, q, strlen(q)); + _write(STDERR_FILENO, p, strlen(p)); suicide = 1; abort(); } @@ -289,10 +289,10 @@ wrtwarning(char *p) char *q = " warning: "; if (malloc_abort) wrterror(p); - _libc_write(STDERR_FILENO, __progname, strlen(__progname)); - _libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func)); - _libc_write(STDERR_FILENO, q, strlen(q)); - _libc_write(STDERR_FILENO, p, strlen(p)); + _write(STDERR_FILENO, __progname, strlen(__progname)); + _write(STDERR_FILENO, malloc_func, strlen(malloc_func)); + _write(STDERR_FILENO, q, strlen(q)); + _write(STDERR_FILENO, p, strlen(p)); } /* diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 1729589..e8e8254 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -298,11 +298,11 @@ srandomdev() len = rand_deg * sizeof state[0]; done = 0; - fd = _libc_open("/dev/urandom", O_RDONLY, 0); + fd = _open("/dev/urandom", O_RDONLY, 0); if (fd >= 0) { - if (_libc_read(fd, (void *) state, len) == (ssize_t) len) + if (_read(fd, (void *) state, len) == (ssize_t) len) done = 1; - _libc_close(fd); + _close(fd); } if (!done) { diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index b956513..0217dde 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -67,7 +67,7 @@ realpath(path, resolved) int symlinks = 0; /* Save the starting point. */ - if ((fd = _libc_open(".", O_RDONLY)) < 0) { + if ((fd = _open(".", O_RDONLY)) < 0) { (void)strcpy(resolved, "."); return (NULL); } @@ -154,12 +154,12 @@ loop: } /* It's okay if the close fails, what's an fd more or less? */ - (void)_libc_close(fd); + (void)_close(fd); return (resolved); err1: serrno = errno; (void)fchdir(fd); -err2: (void)_libc_close(fd); +err2: (void)_close(fd); errno = serrno; return (NULL); } diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index 0039c078..236a8b0 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -84,7 +84,7 @@ __system(command) _exit(127); default: /* parent */ do { - pid = _libc_waitpid(pid, &pstat, 0); + pid = _wait4(pid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); break; } @@ -94,5 +94,4 @@ __system(command) return(pid == -1 ? -1 : pstat); } -__weak_reference(__system, _libc_system); -__weak_reference(_libc_system, system); +__weak_reference(__system, system); diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 34c978b..4fa411f 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -314,7 +314,7 @@ register struct state * const sp; } if (doaccess && access(name, R_OK) != 0) return -1; - if ((fid = _libc_open(name, OPEN_MODE)) == -1) + if ((fid = _open(name, OPEN_MODE)) == -1) return -1; if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) return -1; @@ -325,8 +325,8 @@ register struct state * const sp; int ttisstdcnt; int ttisgmtcnt; - i = _libc_read(fid, buf, sizeof buf); - if (_libc_close(fid) != 0) + i = _read(fid, buf, sizeof buf); + if (_close(fid) != 0) return -1; p = buf; p += (sizeof tzhp->tzh_magic) + (sizeof tzhp->tzh_reserved); diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c index f95dda0..c765cf4 100644 --- a/lib/libc/stdtime/timelocal.c +++ b/lib/libc/stdtime/timelocal.c @@ -157,7 +157,7 @@ __time_load_locale(const char *name) strcat(filename, "/"); strcat(filename, name); strcat(filename, "/LC_TIME"); - fd = _libc_open(filename, O_RDONLY); + fd = _open(filename, O_RDONLY); if (fd < 0) goto no_locale; if (fstat(fd, &st) != 0) @@ -173,9 +173,9 @@ __time_load_locale(const char *name) (void) strcpy(lbuf, name); p = lbuf + namesize; plim = p + st.st_size; - if (_libc_read(fd, p, (size_t) st.st_size) != st.st_size) + if (_read(fd, p, (size_t) st.st_size) != st.st_size) goto bad_lbuf; - if (_libc_close(fd) != 0) + if (_close(fd) != 0) goto bad_lbuf; /* ** Parse the locale file into localebuf. @@ -211,7 +211,7 @@ reset_locale: bad_lbuf: free(lbuf); bad_locale: - (void)_libc_close(fd); + (void)_close(fd); no_locale: _time_using_locale = save_using_locale; return -1; diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 8fc1d56..5c72573 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -350,7 +350,7 @@ _yp_dobind(dom, ypdb) ysd->dom_vers = 0; ysd->dom_client = NULL; sock = dup2(save, sock); - _libc_close(save); + _close(save); } } @@ -373,10 +373,10 @@ again: ysd->dom_socket = -1; } snprintf(path, sizeof(path), "%s/%s.%d", BINDINGDIR, dom, 2); - if((fd = _libc_open(path, O_RDONLY)) == -1) { + if((fd = _open(path, O_RDONLY)) == -1) { /* no binding file, YP is dead. */ /* Try to bring it back to life. */ - _libc_close(fd); + _close(fd); goto skipit; } if( flock(fd, LOCK_EX|LOCK_NB) == -1 && errno==EWOULDBLOCK) { @@ -391,7 +391,7 @@ again: r = readv(fd, iov, 2); if(r != iov[0].iov_len + iov[1].iov_len) { - _libc_close(fd); + _close(fd); ysd->dom_vers = -1; goto again; } @@ -405,12 +405,12 @@ again: *(u_short *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port; ysd->dom_server_port = ysd->dom_server_addr.sin_port; - _libc_close(fd); + _close(fd); goto gotit; } else { /* no lock on binding file, YP is dead. */ /* Try to bring it back to life. */ - _libc_close(fd); + _close(fd); goto skipit; } } @@ -478,9 +478,15 @@ skipit: goto again; } else { if (ypbr.ypbind_status != YPBIND_SUCC_VAL) { + struct timespec time_to_sleep, time_remaining; + clnt_destroy(client); ysd->dom_vers = -1; - _libc_sleep(_yplib_timeout/2); + + time_to_sleep.tv_sec = _yplib_timeout/2; + time_to_sleep.tv_nsec = 0; + _nanosleep(&time_to_sleep, + &time_remaining); goto again; } } @@ -518,7 +524,7 @@ gotit: ysd->dom_vers = -1; goto again; } - if(_libc_fcntl(ysd->dom_socket, F_SETFD, 1) == -1) + if(_fcntl(ysd->dom_socket, F_SETFD, 1) == -1) perror("fcntl: F_SETFD"); /* * We want a port number associated with this socket @@ -567,7 +573,7 @@ _yp_unbind(ypb) save = dup(ypb->dom_socket); clnt_destroy(ypb->dom_client); sock = dup2(save, sock); - _libc_close(save); + _close(save); } else clnt_destroy(ypb->dom_client); } |