mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
update from main archive 961217
Wed Dec 18 03:31:58 1996 Ulrich Drepper <drepper@cygnus.com> * dirent/scandir.c: Undo change from Mon Dec 2 15:32:15 1996. The stream is private and usages outside glibc don't care about reentrancy. * io/fts.c: Likewise. * io/ftw.c: Likewise. * sysdeps/posix/getcwd.c: Likewise. * sysdeps/posix/ttyname.c: Likewise. * sysdeps/posix/ttyname_r.c: Likewise. * sysdeps/posix/glob.c: Likewise. * libio/iovsprintf.c: Add cast to prevent warning. * libio/iovsscanf.c: Likewise. * libio/libioP.h: Define mmap to __mmap and munmap to __munmap to keep namespace clean. * new-malloc/malloc.c: Update to last version from Wolfram Gloger. Add hooks and check functions from old GNU malloc. * new-malloc/malloc.h: Likewise. * nis/ypclnt.c: Remove prototype for xdr_free. * snrpc/rpc/xdr.h: Add prototype for xdr_free. * manual/nss.texi: Correct description of default values and don't meantion NSS as an add-on. * nss/grp-lookup.c: Provide default value as "compat [NOTFOUND=return] files". * nss/pwd-lookup.c: Likewise. * nss/spwd-lookup.c: Likewise. * nss/network-lookup.c: Correct default to "dns [!UNAVAIL=return] files". * nss/nsswitch.c: Change default-default value to "nis [NOTFOUND=return] files" since compat is only available for group, passwd, and shadow. * stdlib/on_exit.c (on_exit): Rename to __on_exit and make old name a weak alias. * stdlib/stdlib.h: Add prototype for __on_exit. * sysdeps/unix/sysv/linux/schedbits.h: Add prototype for __clone. * time/Makefile: Undo change from Sun Dec 8 06:56:49 1996. The new malloc now has mcheck. * time/ap.c: Likewise. * time/tzset.c (__tzset): Rename to __tzset_internal. (tzset): Rename to __tzset. Make tzset a weak alias for __tzset. * time/localtime.c: Use __tzset_internal not __tzset. * time/strftime.c [_LIBC]: Define tzname as __tzname and tzset as __tzset to prevent namespace pollution. * wctype/iswctype.h (icwctype): Rename to __iswctype. Make iswctype a weak alias of __iswctype. * wctype/wctype.h: Add prototype for __iswctype. (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint, iswpunct, iswspace, iswupper, iswxdigit, iswblank): Use __iswctype for the test, not iswctype. 1996-12-16 Paul Eggert <eggert@twinsun.com> * hurd/hurd/sigpreempt.h (struct hurd_signal_preemptor.preemptor, _hurdsig_preemptors), hurd/hurd/signal.h (struct hurd_sigstate.preemptors), hurd/hurdfault.c, hurd/hurdfault.h (_hurdsig_fault_preemptor), hurd/hurdsig.c (_hurdsig_preempters): Renamed to fix spelling from `preempter' to `preemptor'. All uses changed. 1996-12-15 Paul Eggert <eggert@twinsun.com> * ctime.c (ctime): Return asctime (localtime (t)), as the C standard requires. Tue Dec 17 02:05:48 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * sysdeps/mach/libc-lock.h (__libc_lock_trylock): Invert return value because Mach/cthreads uses the opposite convention from Posix/glibc. Mon Dec 16 22:41:01 1996 Ulrich Drepper <drepper@cygnus.com> * stdio-common/fcloseall.c: Correct test of already_called. Reported by Thomas Bushnell, n/BSG. Mon Dec 16 14:52:07 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * mach/lock-intern.h (__mutex_try_lock): New function. Sun Dec 15 16:33:44 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * termios/sys/ttydefaults.h (TTYDEF_OFLAG): Only use OXTABS if defined, else XTABS. (CEOL, CSTATUS): Use _POSIX_VDISABLE if defined. Sun Dec 15 11:56:19 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/mremap.S: New file. * sysdeps/unix/sysv/linux/m68k/Dist: Distribute it. * sysdeps/unix/sysv/linux/m68k/Makefile (sysdep_routines): Add mremap.
This commit is contained in:
103
ChangeLog
103
ChangeLog
@ -1,3 +1,106 @@
|
|||||||
|
Wed Dec 18 03:31:58 1996 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* dirent/scandir.c: Undo change from Mon Dec 2 15:32:15 1996.
|
||||||
|
The stream is private and usages outside glibc don't care about
|
||||||
|
reentrancy.
|
||||||
|
* io/fts.c: Likewise.
|
||||||
|
* io/ftw.c: Likewise.
|
||||||
|
* sysdeps/posix/getcwd.c: Likewise.
|
||||||
|
* sysdeps/posix/ttyname.c: Likewise.
|
||||||
|
* sysdeps/posix/ttyname_r.c: Likewise.
|
||||||
|
* sysdeps/posix/glob.c: Likewise.
|
||||||
|
|
||||||
|
* libio/iovsprintf.c: Add cast to prevent warning.
|
||||||
|
* libio/iovsscanf.c: Likewise.
|
||||||
|
|
||||||
|
* libio/libioP.h: Define mmap to __mmap and munmap to __munmap
|
||||||
|
to keep namespace clean.
|
||||||
|
|
||||||
|
* new-malloc/malloc.c: Update to last version from Wolfram Gloger.
|
||||||
|
Add hooks and check functions from old GNU malloc.
|
||||||
|
* new-malloc/malloc.h: Likewise.
|
||||||
|
|
||||||
|
* nis/ypclnt.c: Remove prototype for xdr_free.
|
||||||
|
* snrpc/rpc/xdr.h: Add prototype for xdr_free.
|
||||||
|
|
||||||
|
* manual/nss.texi: Correct description of default values and don't
|
||||||
|
meantion NSS as an add-on.
|
||||||
|
|
||||||
|
* nss/grp-lookup.c: Provide default value as
|
||||||
|
"compat [NOTFOUND=return] files".
|
||||||
|
* nss/pwd-lookup.c: Likewise.
|
||||||
|
* nss/spwd-lookup.c: Likewise.
|
||||||
|
* nss/network-lookup.c: Correct default to
|
||||||
|
"dns [!UNAVAIL=return] files".
|
||||||
|
* nss/nsswitch.c: Change default-default value to "nis
|
||||||
|
[NOTFOUND=return] files" since compat is only available for group,
|
||||||
|
passwd, and shadow.
|
||||||
|
|
||||||
|
* stdlib/on_exit.c (on_exit): Rename to __on_exit and make old name
|
||||||
|
a weak alias.
|
||||||
|
* stdlib/stdlib.h: Add prototype for __on_exit.
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/schedbits.h: Add prototype for __clone.
|
||||||
|
|
||||||
|
* time/Makefile: Undo change from Sun Dec 8 06:56:49 1996.
|
||||||
|
The new malloc now has mcheck.
|
||||||
|
* time/ap.c: Likewise.
|
||||||
|
|
||||||
|
* time/tzset.c (__tzset): Rename to __tzset_internal.
|
||||||
|
(tzset): Rename to __tzset. Make tzset a weak alias for __tzset.
|
||||||
|
* time/localtime.c: Use __tzset_internal not __tzset.
|
||||||
|
* time/strftime.c [_LIBC]: Define tzname as __tzname and tzset
|
||||||
|
as __tzset to prevent namespace pollution.
|
||||||
|
|
||||||
|
* wctype/iswctype.h (icwctype): Rename to __iswctype. Make iswctype
|
||||||
|
a weak alias of __iswctype.
|
||||||
|
* wctype/wctype.h: Add prototype for __iswctype.
|
||||||
|
(iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph,
|
||||||
|
iswprint, iswpunct, iswspace, iswupper, iswxdigit, iswblank):
|
||||||
|
Use __iswctype for the test, not iswctype.
|
||||||
|
|
||||||
|
1996-12-16 Paul Eggert <eggert@twinsun.com>
|
||||||
|
|
||||||
|
* hurd/hurd/sigpreempt.h
|
||||||
|
(struct hurd_signal_preemptor.preemptor, _hurdsig_preemptors),
|
||||||
|
hurd/hurd/signal.h (struct hurd_sigstate.preemptors),
|
||||||
|
hurd/hurdfault.c, hurd/hurdfault.h (_hurdsig_fault_preemptor),
|
||||||
|
hurd/hurdsig.c (_hurdsig_preempters):
|
||||||
|
Renamed to fix spelling from `preempter' to `preemptor'.
|
||||||
|
All uses changed.
|
||||||
|
|
||||||
|
1996-12-15 Paul Eggert <eggert@twinsun.com>
|
||||||
|
|
||||||
|
* ctime.c (ctime): Return asctime (localtime (t)), as the C
|
||||||
|
standard requires.
|
||||||
|
|
||||||
|
Tue Dec 17 02:05:48 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* sysdeps/mach/libc-lock.h (__libc_lock_trylock): Invert return
|
||||||
|
value because Mach/cthreads uses the opposite convention from
|
||||||
|
Posix/glibc.
|
||||||
|
|
||||||
|
Mon Dec 16 22:41:01 1996 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* stdio-common/fcloseall.c: Correct test of already_called.
|
||||||
|
Reported by Thomas Bushnell, n/BSG.
|
||||||
|
|
||||||
|
Mon Dec 16 14:52:07 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* mach/lock-intern.h (__mutex_try_lock): New function.
|
||||||
|
|
||||||
|
Sun Dec 15 16:33:44 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||||
|
|
||||||
|
* termios/sys/ttydefaults.h (TTYDEF_OFLAG): Only use OXTABS if
|
||||||
|
defined, else XTABS.
|
||||||
|
(CEOL, CSTATUS): Use _POSIX_VDISABLE if defined.
|
||||||
|
|
||||||
|
Sun Dec 15 11:56:19 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/m68k/mremap.S: New file.
|
||||||
|
* sysdeps/unix/sysv/linux/m68k/Dist: Distribute it.
|
||||||
|
* sysdeps/unix/sysv/linux/m68k/Makefile (sysdep_routines): Add mremap.
|
||||||
|
|
||||||
Mon Dec 16 02:15:42 1996 Ulrich Drepper <drepper@cygnus.com>
|
Mon Dec 16 02:15:42 1996 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
Make sure tzset() sets always tzname[].
|
Make sure tzset() sets always tzname[].
|
||||||
|
@ -31,7 +31,7 @@ scandir (dir, namelist, select, cmp)
|
|||||||
DIR *dp = opendir (dir);
|
DIR *dp = opendir (dir);
|
||||||
struct dirent **v = NULL;
|
struct dirent **v = NULL;
|
||||||
size_t vsize = 0, i;
|
size_t vsize = 0, i;
|
||||||
struct dirent dirbuf, *d;
|
struct dirent *d;
|
||||||
int save;
|
int save;
|
||||||
|
|
||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
@ -41,7 +41,7 @@ scandir (dir, namelist, select, cmp)
|
|||||||
__set_errno (0);
|
__set_errno (0);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (__readdir_r (dp, &dirbuf, &d) >= 0)
|
while ((d = __readdir (dp)) != NULL)
|
||||||
if (select == NULL || (*select) (d))
|
if (select == NULL || (*select) (d))
|
||||||
{
|
{
|
||||||
size_t dsize;
|
size_t dsize;
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <hurd/signal.h>
|
#include <hurd/signal.h>
|
||||||
#include <hurd/sigpreempt.h>
|
#include <hurd/sigpreempt.h>
|
||||||
@ -25,14 +25,14 @@ Cambridge, MA 02139, USA. */
|
|||||||
error_t
|
error_t
|
||||||
hurd_catch_signal (sigset_t sigset,
|
hurd_catch_signal (sigset_t sigset,
|
||||||
unsigned long int first, unsigned long int last,
|
unsigned long int first, unsigned long int last,
|
||||||
error_t (*operate) (struct hurd_signal_preempter *),
|
error_t (*operate) (struct hurd_signal_preemptor *),
|
||||||
sighandler_t handler)
|
sighandler_t handler)
|
||||||
{
|
{
|
||||||
jmp_buf buf;
|
jmp_buf buf;
|
||||||
void throw (int signo, long int sigcode, struct sigcontext *scp)
|
void throw (int signo, long int sigcode, struct sigcontext *scp)
|
||||||
{ longjmp (buf, scp->sc_error ?: EGRATUITOUS); }
|
{ longjmp (buf, scp->sc_error ?: EGRATUITOUS); }
|
||||||
|
|
||||||
struct hurd_signal_preempter preempter =
|
struct hurd_signal_preemptor preemptor =
|
||||||
{
|
{
|
||||||
sigset, first, last,
|
sigset, first, last,
|
||||||
NULL, handler == SIG_ERR ? (sighandler_t) &throw : handler,
|
NULL, handler == SIG_ERR ? (sighandler_t) &throw : handler,
|
||||||
@ -50,23 +50,23 @@ hurd_catch_signal (sigset_t sigset,
|
|||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
/* Install a signal preempter for the thread. */
|
/* Install a signal preemptor for the thread. */
|
||||||
__spin_lock (&ss->lock);
|
__spin_lock (&ss->lock);
|
||||||
preempter.next = ss->preempters;
|
preemptor.next = ss->preemptors;
|
||||||
ss->preempters = &preempter;
|
ss->preemptors = &preemptor;
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
/* Try the operation that might crash. */
|
/* Try the operation that might crash. */
|
||||||
(*operate) (&preempter);
|
(*operate) (&preemptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Either FUNCTION completed happily and ERROR is still zero, or it hit
|
/* Either FUNCTION completed happily and ERROR is still zero, or it hit
|
||||||
an expected signal and `throw' made setjmp return the signal error
|
an expected signal and `throw' made setjmp return the signal error
|
||||||
code in ERROR. Now we can remove the preempter and return. */
|
code in ERROR. Now we can remove the preemptor and return. */
|
||||||
|
|
||||||
__spin_lock (&ss->lock);
|
__spin_lock (&ss->lock);
|
||||||
assert (ss->preempters == &preempter);
|
assert (ss->preemptors == &preemptor);
|
||||||
ss->preempters = preempter.next;
|
ss->preemptors = preemptor.next;
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -76,7 +76,7 @@ hurd_catch_signal (sigset_t sigset,
|
|||||||
error_t
|
error_t
|
||||||
hurd_safe_memset (void *dest, int byte, size_t nbytes)
|
hurd_safe_memset (void *dest, int byte, size_t nbytes)
|
||||||
{
|
{
|
||||||
error_t operate (struct hurd_signal_preempter *preempter)
|
error_t operate (struct hurd_signal_preemptor *preemptor)
|
||||||
{
|
{
|
||||||
memset (dest, byte, nbytes);
|
memset (dest, byte, nbytes);
|
||||||
return 0;
|
return 0;
|
||||||
@ -90,7 +90,7 @@ hurd_safe_memset (void *dest, int byte, size_t nbytes)
|
|||||||
error_t
|
error_t
|
||||||
hurd_safe_copyout (void *dest, const void *src, size_t nbytes)
|
hurd_safe_copyout (void *dest, const void *src, size_t nbytes)
|
||||||
{
|
{
|
||||||
error_t operate (struct hurd_signal_preempter *preempter)
|
error_t operate (struct hurd_signal_preemptor *preemptor)
|
||||||
{
|
{
|
||||||
memcpy (dest, src, nbytes);
|
memcpy (dest, src, nbytes);
|
||||||
return 0;
|
return 0;
|
||||||
@ -103,7 +103,7 @@ hurd_safe_copyout (void *dest, const void *src, size_t nbytes)
|
|||||||
error_t
|
error_t
|
||||||
hurd_safe_copyin (void *dest, const void *src, size_t nbytes)
|
hurd_safe_copyin (void *dest, const void *src, size_t nbytes)
|
||||||
{
|
{
|
||||||
error_t operate (struct hurd_signal_preempter *preempter)
|
error_t operate (struct hurd_signal_preemptor *preemptor)
|
||||||
{
|
{
|
||||||
memcpy (dest, src, nbytes);
|
memcpy (dest, src, nbytes);
|
||||||
return 0;
|
return 0;
|
||||||
@ -120,18 +120,18 @@ hurd_safe_memmove (void *dest, const void *src, size_t nbytes)
|
|||||||
void throw (int signo, long int sigcode, struct sigcontext *scp)
|
void throw (int signo, long int sigcode, struct sigcontext *scp)
|
||||||
{ longjmp (buf, scp->sc_error ?: EGRATUITOUS); }
|
{ longjmp (buf, scp->sc_error ?: EGRATUITOUS); }
|
||||||
|
|
||||||
struct hurd_signal_preempter src_preempter =
|
struct hurd_signal_preemptor src_preemptor =
|
||||||
{
|
{
|
||||||
sigmask (SIGBUS) | sigmask (SIGSEGV),
|
sigmask (SIGBUS) | sigmask (SIGSEGV),
|
||||||
(vm_address_t) src, (vm_address_t) src + nbytes,
|
(vm_address_t) src, (vm_address_t) src + nbytes,
|
||||||
NULL, (sighandler_t) &throw,
|
NULL, (sighandler_t) &throw,
|
||||||
};
|
};
|
||||||
struct hurd_signal_preempter dest_preempter =
|
struct hurd_signal_preemptor dest_preemptor =
|
||||||
{
|
{
|
||||||
sigmask (SIGBUS) | sigmask (SIGSEGV),
|
sigmask (SIGBUS) | sigmask (SIGSEGV),
|
||||||
(vm_address_t) dest, (vm_address_t) dest + nbytes,
|
(vm_address_t) dest, (vm_address_t) dest + nbytes,
|
||||||
NULL, (sighandler_t) &throw,
|
NULL, (sighandler_t) &throw,
|
||||||
&src_preempter
|
&src_preemptor
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hurd_sigstate *const ss = _hurd_self_sigstate ();
|
struct hurd_sigstate *const ss = _hurd_self_sigstate ();
|
||||||
@ -142,10 +142,10 @@ hurd_safe_memmove (void *dest, const void *src, size_t nbytes)
|
|||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
/* Install a signal preempter for the thread. */
|
/* Install a signal preemptor for the thread. */
|
||||||
__spin_lock (&ss->lock);
|
__spin_lock (&ss->lock);
|
||||||
src_preempter.next = ss->preempters;
|
src_preemptor.next = ss->preemptors;
|
||||||
ss->preempters = &dest_preempter;
|
ss->preemptors = &dest_preemptor;
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
/* Do the copy; it might fault. */
|
/* Do the copy; it might fault. */
|
||||||
@ -154,13 +154,12 @@ hurd_safe_memmove (void *dest, const void *src, size_t nbytes)
|
|||||||
|
|
||||||
/* Either memmove completed happily and ERROR is still zero, or it hit
|
/* Either memmove completed happily and ERROR is still zero, or it hit
|
||||||
an expected signal and `throw' made setjmp return the signal error
|
an expected signal and `throw' made setjmp return the signal error
|
||||||
code in ERROR. Now we can remove the preempter and return. */
|
code in ERROR. Now we can remove the preemptor and return. */
|
||||||
|
|
||||||
__spin_lock (&ss->lock);
|
__spin_lock (&ss->lock);
|
||||||
assert (ss->preempters == &dest_preempter);
|
assert (ss->preemptors == &dest_preemptor);
|
||||||
ss->preempters = src_preempter.next;
|
ss->preemptors = src_preemptor.next;
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _HURD_SIGNAL_H
|
#ifndef _HURD_SIGNAL_H
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <cthreads.h> /* For `struct mutex'. */
|
#include <cthreads.h> /* For `struct mutex'. */
|
||||||
#include <spin-lock.h>
|
#include <spin-lock.h>
|
||||||
#include <hurd/threadvar.h> /* We cache sigstate in a threadvar. */
|
#include <hurd/threadvar.h> /* We cache sigstate in a threadvar. */
|
||||||
struct hurd_signal_preempter; /* <hurd/sigpreempt.h> */
|
struct hurd_signal_preemptor; /* <hurd/sigpreempt.h> */
|
||||||
|
|
||||||
|
|
||||||
/* Full details of a signal. */
|
/* Full details of a signal. */
|
||||||
@ -71,11 +71,11 @@ struct hurd_sigstate
|
|||||||
struct sigaction actions[NSIG];
|
struct sigaction actions[NSIG];
|
||||||
struct sigaltstack sigaltstack;
|
struct sigaltstack sigaltstack;
|
||||||
|
|
||||||
/* Chain of thread-local signal preempters; see <hurd/sigpreempt.h>.
|
/* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>.
|
||||||
Each element of this chain is in local stack storage, and the chain
|
Each element of this chain is in local stack storage, and the chain
|
||||||
parallels the stack: the head of this chain is in the innermost
|
parallels the stack: the head of this chain is in the innermost
|
||||||
stack frame, and each next element in an outermore frame. */
|
stack frame, and each next element in an outermore frame. */
|
||||||
struct hurd_signal_preempter *preempters;
|
struct hurd_signal_preemptor *preemptors;
|
||||||
|
|
||||||
/* For each signal that may be pending, the details to deliver it with. */
|
/* For each signal that may be pending, the details to deliver it with. */
|
||||||
struct hurd_signal_detail pending_data[NSIG];
|
struct hurd_signal_detail pending_data[NSIG];
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _HURD_SIGPREEMPT_H
|
#ifndef _HURD_SIGPREEMPT_H
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
struct hurd_sigstate; /* <hurd/signal.h> */
|
struct hurd_sigstate; /* <hurd/signal.h> */
|
||||||
struct hurd_signal_detail; /* <hurd/signal.h> */
|
struct hurd_signal_detail; /* <hurd/signal.h> */
|
||||||
|
|
||||||
struct hurd_signal_preempter
|
struct hurd_signal_preemptor
|
||||||
{
|
{
|
||||||
/* These members select which signals this structure will apply to.
|
/* These members select which signals this structure will apply to.
|
||||||
The rest of the structure is only consulted if these match. */
|
The rest of the structure is only consulted if these match. */
|
||||||
@ -34,35 +34,35 @@ struct hurd_signal_preempter
|
|||||||
|
|
||||||
/* This function will be called (with SS->lock held) to decide what to
|
/* This function will be called (with SS->lock held) to decide what to
|
||||||
do with the signal described. It may modify the codes of the signal
|
do with the signal described. It may modify the codes of the signal
|
||||||
passed. If the return value is SIG_ERR, the next matching preempter
|
passed. If the return value is SIG_ERR, the next matching preemptor
|
||||||
is tried, or the normal handling is done for the signal (which may
|
is tried, or the normal handling is done for the signal (which may
|
||||||
have been changed by the preempter function). Otherwise, the signal
|
have been changed by the preemptor function). Otherwise, the signal
|
||||||
is processed as if the return value were its handler setting. */
|
is processed as if the return value were its handler setting. */
|
||||||
sighandler_t (*preempter) (struct hurd_signal_preempter *preempter,
|
sighandler_t (*preemptor) (struct hurd_signal_preemptor *preemptor,
|
||||||
struct hurd_sigstate *ss,
|
struct hurd_sigstate *ss,
|
||||||
int *signo, struct hurd_signal_detail *detail);
|
int *signo, struct hurd_signal_detail *detail);
|
||||||
/* If PREEMPTER is null, act as if it returned HANDLER. */
|
/* If PREEMPTOR is null, act as if it returned HANDLER. */
|
||||||
sighandler_t handler;
|
sighandler_t handler;
|
||||||
|
|
||||||
struct hurd_signal_preempter *next; /* List structure. */
|
struct hurd_signal_preemptor *next; /* List structure. */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HURD_PREEMPT_SIGNAL_P(preempter, signo, sigcode) \
|
#define HURD_PREEMPT_SIGNAL_P(preemptor, signo, sigcode) \
|
||||||
(((preempter)->signals & sigmask (signo)) && \
|
(((preemptor)->signals & sigmask (signo)) && \
|
||||||
(sigcode) >= (preempter)->first && (sigcode) <= (preempter)->last)
|
(sigcode) >= (preemptor)->first && (sigcode) <= (preemptor)->last)
|
||||||
|
|
||||||
|
|
||||||
/* Signal preempters applying to all threads; locked by _hurd_siglock. */
|
/* Signal preemptors applying to all threads; locked by _hurd_siglock. */
|
||||||
extern struct hurd_signal_preempter *_hurdsig_preempters;
|
extern struct hurd_signal_preemptor *_hurdsig_preemptors;
|
||||||
extern sigset_t _hurdsig_preempted_set;
|
extern sigset_t _hurdsig_preempted_set;
|
||||||
|
|
||||||
|
|
||||||
/* The caller must initialize all members of *PREEMPTER except `next'.
|
/* The caller must initialize all members of *PREEMPTOR except `next'.
|
||||||
The preempter is registered on the global list. */
|
The preemptor is registered on the global list. */
|
||||||
void hurd_preempt_signals (struct hurd_signal_preempter *preempter);
|
void hurd_preempt_signals (struct hurd_signal_preemptor *preemptor);
|
||||||
|
|
||||||
/* Remove a preempter registered with hurd_preempt_signals. */
|
/* Remove a preemptor registered with hurd_preempt_signals. */
|
||||||
void hurd_unpreempt_signals (struct hurd_signal_preempter *preempter);
|
void hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor);
|
||||||
|
|
||||||
|
|
||||||
/* Call *OPERATE and return its value. If a signal in SIGSET with a sigcode
|
/* Call *OPERATE and return its value. If a signal in SIGSET with a sigcode
|
||||||
@ -72,13 +72,13 @@ void hurd_unpreempt_signals (struct hurd_signal_preempter *preempter);
|
|||||||
hurd_catch_signal returns the sc_error value from the signal (or
|
hurd_catch_signal returns the sc_error value from the signal (or
|
||||||
EGRATUITOUS if that is zero).
|
EGRATUITOUS if that is zero).
|
||||||
|
|
||||||
The preempter structure is passed to *OPERATE, which may modify its
|
The preemptor structure is passed to *OPERATE, which may modify its
|
||||||
sigcode range or functions at any time during which it is guaranteed no
|
sigcode range or functions at any time during which it is guaranteed no
|
||||||
signal in SIGSET will arrive. */
|
signal in SIGSET will arrive. */
|
||||||
|
|
||||||
error_t hurd_catch_signal (sigset_t sigset,
|
error_t hurd_catch_signal (sigset_t sigset,
|
||||||
unsigned long int first, unsigned long int last,
|
unsigned long int first, unsigned long int last,
|
||||||
error_t (*operate) (struct hurd_signal_preempter *),
|
error_t (*operate) (struct hurd_signal_preemptor *),
|
||||||
sighandler_t handler);
|
sighandler_t handler);
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/signal.h>
|
#include <hurd/signal.h>
|
||||||
@ -29,7 +29,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
jmp_buf _hurdsig_fault_env;
|
jmp_buf _hurdsig_fault_env;
|
||||||
struct hurd_signal_preempter _hurdsig_fault_preempter;
|
struct hurd_signal_preemptor _hurdsig_fault_preemptor;
|
||||||
|
|
||||||
static mach_port_t forward_sigexc;
|
static mach_port_t forward_sigexc;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ _hurdsig_fault_catch_exception_raise (mach_port_t port,
|
|||||||
codes into a signal number and subcode. */
|
codes into a signal number and subcode. */
|
||||||
_hurd_exception2signal (&d, &signo);
|
_hurd_exception2signal (&d, &signo);
|
||||||
|
|
||||||
return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preempter, signo, d.code)
|
return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.code)
|
||||||
? 0 : EGREGIOUS;
|
? 0 : EGREGIOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ faulted (void)
|
|||||||
if (reply.result)
|
if (reply.result)
|
||||||
__libc_fatal ("BUG: unexpected fault in signal thread\n");
|
__libc_fatal ("BUG: unexpected fault in signal thread\n");
|
||||||
|
|
||||||
_hurdsig_fault_preempter.signals = 0;
|
_hurdsig_fault_preemptor.signals = 0;
|
||||||
longjmp (_hurdsig_fault_env, 1);
|
longjmp (_hurdsig_fault_env, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,4 +158,3 @@ _hurdsig_fault_init (void)
|
|||||||
__mach_port_deallocate (__mach_task_self (), sigexc);
|
__mach_port_deallocate (__mach_task_self (), sigexc);
|
||||||
assert_perror (err);
|
assert_perror (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _HURD_FAULT_H
|
#ifndef _HURD_FAULT_H
|
||||||
#define _HURD_FAULT_H
|
#define _HURD_FAULT_H
|
||||||
@ -29,18 +29,18 @@ Cambridge, MA 02139, USA. */
|
|||||||
does arrive. */
|
does arrive. */
|
||||||
|
|
||||||
#define _hurdsig_catch_fault(sigset, firstcode, lastcode) \
|
#define _hurdsig_catch_fault(sigset, firstcode, lastcode) \
|
||||||
(_hurdsig_fault_preempter.signals = (sigset), \
|
(_hurdsig_fault_preemptor.signals = (sigset), \
|
||||||
_hurdsig_fault_preempter.first = (long int) (firstcode), \
|
_hurdsig_fault_preemptor.first = (long int) (firstcode), \
|
||||||
_hurdsig_fault_preempter.last = (long int) (lastcode), \
|
_hurdsig_fault_preemptor.last = (long int) (lastcode), \
|
||||||
setjmp (_hurdsig_fault_env))
|
setjmp (_hurdsig_fault_env))
|
||||||
|
|
||||||
/* Call this at the end of a section protected by _hurdsig_catch_fault. */
|
/* Call this at the end of a section protected by _hurdsig_catch_fault. */
|
||||||
|
|
||||||
#define _hurdsig_end_catch_fault() \
|
#define _hurdsig_end_catch_fault() \
|
||||||
(_hurdsig_fault_preempter.signals = 0)
|
(_hurdsig_fault_preemptor.signals = 0)
|
||||||
|
|
||||||
extern jmp_buf _hurdsig_fault_env;
|
extern jmp_buf _hurdsig_fault_env;
|
||||||
extern struct hurd_signal_preempter _hurdsig_fault_preempter;
|
extern struct hurd_signal_preemptor _hurdsig_fault_preemptor;
|
||||||
|
|
||||||
|
|
||||||
#define _hurdsig_catch_memory_fault(object) \
|
#define _hurdsig_catch_memory_fault(object) \
|
||||||
|
@ -78,7 +78,7 @@ _hurd_thread_sigstate (thread_t thread)
|
|||||||
__sigemptyset (&ss->blocked);
|
__sigemptyset (&ss->blocked);
|
||||||
__sigemptyset (&ss->pending);
|
__sigemptyset (&ss->pending);
|
||||||
memset (&ss->sigaltstack, 0, sizeof (ss->sigaltstack));
|
memset (&ss->sigaltstack, 0, sizeof (ss->sigaltstack));
|
||||||
ss->preempters = NULL;
|
ss->preemptors = NULL;
|
||||||
ss->suspended = 0;
|
ss->suspended = 0;
|
||||||
ss->intr_port = MACH_PORT_NULL;
|
ss->intr_port = MACH_PORT_NULL;
|
||||||
ss->context = NULL;
|
ss->context = NULL;
|
||||||
@ -421,7 +421,7 @@ abort_all_rpcs (int signo, struct machine_thread_all_state *state, int live)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hurd_signal_preempter *_hurdsig_preempters;
|
struct hurd_signal_preemptor *_hurdsig_preemptors;
|
||||||
sigset_t _hurdsig_preempted_set;
|
sigset_t _hurdsig_preempted_set;
|
||||||
|
|
||||||
/* Mask of stop signals. */
|
/* Mask of stop signals. */
|
||||||
@ -439,7 +439,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss,
|
|||||||
error_t err;
|
error_t err;
|
||||||
struct machine_thread_all_state thread_state;
|
struct machine_thread_all_state thread_state;
|
||||||
enum { stop, ignore, core, term, handle } act;
|
enum { stop, ignore, core, term, handle } act;
|
||||||
struct hurd_signal_preempter *pe;
|
struct hurd_signal_preemptor *pe;
|
||||||
sighandler_t handler;
|
sighandler_t handler;
|
||||||
sigset_t pending;
|
sigset_t pending;
|
||||||
int ss_suspended;
|
int ss_suspended;
|
||||||
@ -542,16 +542,16 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss,
|
|||||||
critical sections. */
|
critical sections. */
|
||||||
|
|
||||||
handler = SIG_ERR;
|
handler = SIG_ERR;
|
||||||
for (pe = ss->preempters; pe && handler == SIG_ERR; pe = pe->next)
|
for (pe = ss->preemptors; pe && handler == SIG_ERR; pe = pe->next)
|
||||||
if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
|
if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
|
||||||
handler = (*pe->preempter) (pe, ss, &signo, detail);
|
handler = (*pe->preemptor) (pe, ss, &signo, detail);
|
||||||
|
|
||||||
if (handler == SIG_ERR && (__sigmask (signo) & _hurdsig_preempted_set))
|
if (handler == SIG_ERR && (__sigmask (signo) & _hurdsig_preempted_set))
|
||||||
{
|
{
|
||||||
__mutex_lock (&_hurd_siglock);
|
__mutex_lock (&_hurd_siglock);
|
||||||
for (pe = _hurdsig_preempters; pe && handler == SIG_ERR; pe = pe->next)
|
for (pe = _hurdsig_preemptors; pe && handler == SIG_ERR; pe = pe->next)
|
||||||
if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
|
if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
|
||||||
handler = (*pe->preempter) (pe, ss, &signo, detail);
|
handler = (*pe->preemptor) (pe, ss, &signo, detail);
|
||||||
__mutex_unlock (&_hurd_siglock);
|
__mutex_unlock (&_hurd_siglock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,22 +1250,22 @@ _hurdsig_getenv (const char *variable)
|
|||||||
while (*ep)
|
while (*ep)
|
||||||
{
|
{
|
||||||
const char *p = *ep;
|
const char *p = *ep;
|
||||||
_hurdsig_fault_preempter.first = (long int) p;
|
_hurdsig_fault_preemptor.first = (long int) p;
|
||||||
_hurdsig_fault_preempter.last = VM_MAX_ADDRESS;
|
_hurdsig_fault_preemptor.last = VM_MAX_ADDRESS;
|
||||||
if (! strncmp (p, variable, len) && p[len] == '=')
|
if (! strncmp (p, variable, len) && p[len] == '=')
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
size_t valuelen;
|
size_t valuelen;
|
||||||
p += len + 1;
|
p += len + 1;
|
||||||
valuelen = strlen (p);
|
valuelen = strlen (p);
|
||||||
_hurdsig_fault_preempter.last = (long int) (p + valuelen);
|
_hurdsig_fault_preemptor.last = (long int) (p + valuelen);
|
||||||
value = malloc (++valuelen);
|
value = malloc (++valuelen);
|
||||||
if (value)
|
if (value)
|
||||||
memcpy (value, p, valuelen);
|
memcpy (value, p, valuelen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_hurdsig_fault_preempter.first = (long int) ++ep;
|
_hurdsig_fault_preemptor.first = (long int) ++ep;
|
||||||
_hurdsig_fault_preempter.last = (long int) (ep + 1);
|
_hurdsig_fault_preemptor.last = (long int) (ep + 1);
|
||||||
}
|
}
|
||||||
_hurdsig_end_catch_fault ();
|
_hurdsig_end_catch_fault ();
|
||||||
return value;
|
return value;
|
||||||
|
@ -12,44 +12,44 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <hurd/sigpreempt.h>
|
#include <hurd/sigpreempt.h>
|
||||||
#include <hurd/signal.h>
|
#include <hurd/signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
hurd_preempt_signals (struct hurd_signal_preempter *preempter)
|
hurd_preempt_signals (struct hurd_signal_preemptor *preemptor)
|
||||||
{
|
{
|
||||||
__mutex_lock (&_hurd_siglock);
|
__mutex_lock (&_hurd_siglock);
|
||||||
preempter->next = _hurdsig_preempters;
|
preemptor->next = _hurdsig_preemptors;
|
||||||
_hurdsig_preempters = preempter;
|
_hurdsig_preemptors = preemptor;
|
||||||
_hurdsig_preempted_set |= preempter->signals;
|
_hurdsig_preempted_set |= preemptor->signals;
|
||||||
__mutex_unlock (&_hurd_siglock);
|
__mutex_unlock (&_hurd_siglock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hurd_unpreempt_signals (struct hurd_signal_preempter *preempter)
|
hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor)
|
||||||
{
|
{
|
||||||
struct hurd_signal_preempter **p;
|
struct hurd_signal_preemptor **p;
|
||||||
sigset_t preempted = 0;
|
sigset_t preempted = 0;
|
||||||
|
|
||||||
__mutex_lock (&_hurd_siglock);
|
__mutex_lock (&_hurd_siglock);
|
||||||
|
|
||||||
p = &_hurdsig_preempters;
|
p = &_hurdsig_preemptors;
|
||||||
while (*p)
|
while (*p)
|
||||||
if (*p == preempter)
|
if (*p == preemptor)
|
||||||
{
|
{
|
||||||
/* Found it; take it off the chain. */
|
/* Found it; take it off the chain. */
|
||||||
*p = (*p)->next;
|
*p = (*p)->next;
|
||||||
if ((preempter->signals & preempted) != preempter->signals)
|
if ((preemptor->signals & preempted) != preemptor->signals)
|
||||||
{
|
{
|
||||||
/* This might have been the only preempter for some
|
/* This might have been the only preemptor for some
|
||||||
of those signals, so we must collect the full mask
|
of those signals, so we must collect the full mask
|
||||||
from the others. */
|
from the others. */
|
||||||
struct hurd_signal_preempter *pp;
|
struct hurd_signal_preemptor *pp;
|
||||||
for (pp = *p; pp; pp = pp->next)
|
for (pp = *p; pp; pp = pp->next)
|
||||||
preempted |= pp->signals;
|
preempted |= pp->signals;
|
||||||
_hurdsig_preempted_set = preempted;
|
_hurdsig_preempted_set = preempted;
|
||||||
@ -64,5 +64,5 @@ hurd_unpreempt_signals (struct hurd_signal_preempter *preempter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
__mutex_unlock (&_hurd_siglock); /* Avoid deadlock during death rattle. */
|
__mutex_unlock (&_hurd_siglock); /* Avoid deadlock during death rattle. */
|
||||||
assert (! "removing absent preempter");
|
assert (! "removing absent preemptor");
|
||||||
}
|
}
|
||||||
|
5
io/fts.c
5
io/fts.c
@ -570,7 +570,7 @@ fts_build(sp, type)
|
|||||||
register FTS *sp;
|
register FTS *sp;
|
||||||
int type;
|
int type;
|
||||||
{
|
{
|
||||||
struct dirent dirbuf, *dp;
|
struct dirent *dp;
|
||||||
register FTSENT *p, *head;
|
register FTSENT *p, *head;
|
||||||
register int nitems;
|
register int nitems;
|
||||||
FTSENT *cur, *tail;
|
FTSENT *cur, *tail;
|
||||||
@ -660,8 +660,7 @@ fts_build(sp, type)
|
|||||||
|
|
||||||
/* Read the directory, attaching each entry to the `link' pointer. */
|
/* Read the directory, attaching each entry to the `link' pointer. */
|
||||||
adjaddr = NULL;
|
adjaddr = NULL;
|
||||||
for (head = tail = NULL, nitems = 0;
|
for (head = tail = NULL, nitems = 0; dp = readdir(dirp);) {
|
||||||
__readdir_r (dirp, &dirbuf, &dp) >= 0;) {
|
|
||||||
int namlen;
|
int namlen;
|
||||||
|
|
||||||
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
|
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
|
||||||
|
6
io/ftw.c
6
io/ftw.c
@ -39,13 +39,13 @@ ftw_dir (DIR **dirs, int level, int descriptors, char *dir, size_t len,
|
|||||||
int (*func) (const char *file, struct stat *status, int flag))
|
int (*func) (const char *file, struct stat *status, int flag))
|
||||||
{
|
{
|
||||||
int got;
|
int got;
|
||||||
struct dirent dirbuf, *entry;
|
struct dirent *entry;
|
||||||
|
|
||||||
got = 0;
|
got = 0;
|
||||||
|
|
||||||
__set_errno (0);
|
__set_errno (0);
|
||||||
|
|
||||||
while (__readdir_r (dirs[level], &dirbuf, &entry) >= 0)
|
while ((entry = readdir (dirs[level])) != NULL)
|
||||||
{
|
{
|
||||||
struct stat s;
|
struct stat s;
|
||||||
int flag, retval, newlev;
|
int flag, retval, newlev;
|
||||||
@ -136,7 +136,7 @@ ftw_dir (DIR **dirs, int level, int descriptors, char *dir, size_t len,
|
|||||||
while (skip-- != 0)
|
while (skip-- != 0)
|
||||||
{
|
{
|
||||||
__set_errno (0);
|
__set_errno (0);
|
||||||
if (__readdir_r (dirs[level], &dirbuf, &entry) < 0)
|
if (readdir (dirs[level]) == NULL)
|
||||||
return errno == 0 ? 0 : -1;
|
return errno == 0 ? 0 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ _IO_vsprintf (string, format, args)
|
|||||||
_IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
|
_IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
|
||||||
_IO_str_init_static ((_IO_FILE *) &sf, string, -1, string);
|
_IO_str_init_static ((_IO_FILE *) &sf, string, -1, string);
|
||||||
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, &sf);
|
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, &sf);
|
||||||
_IO_flockfile (&sf);
|
_IO_flockfile ((_IO_FILE *) &sf);
|
||||||
ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
|
ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
|
||||||
_IO_putc_unlocked ('\0', (_IO_FILE *) &sf);
|
_IO_putc_unlocked ('\0', (_IO_FILE *) &sf);
|
||||||
_IO_cleanup_region_end (1);
|
_IO_cleanup_region_end (1);
|
||||||
|
@ -39,7 +39,7 @@ DEFUN(_IO_vsscanf, (string, format, args),
|
|||||||
_IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps;
|
_IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps;
|
||||||
_IO_str_init_static ((_IO_FILE*)&sf, (char*)string, 0, NULL);
|
_IO_str_init_static ((_IO_FILE*)&sf, (char*)string, 0, NULL);
|
||||||
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, &sf);
|
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, &sf);
|
||||||
_IO_flockfile (&sf);
|
_IO_flockfile ((_IO_FILE *) &sf);
|
||||||
ret = _IO_vfscanf((_IO_FILE*)&sf, format, args, NULL);
|
ret = _IO_vfscanf((_IO_FILE*)&sf, format, args, NULL);
|
||||||
_IO_cleanup_region_end (1);
|
_IO_cleanup_region_end (1);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -428,6 +428,12 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
|
|||||||
|
|
||||||
#if _G_HAVE_MMAP
|
#if _G_HAVE_MMAP
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
/* When using this code in the GNU libc we must not pollute the name space. */
|
||||||
|
#define mmap __mmap
|
||||||
|
#define munmap __munmap
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ROUND_TO_PAGE(_S) \
|
#define ROUND_TO_PAGE(_S) \
|
||||||
(((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
|
(((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1994, 1996 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -12,9 +12,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _LOCK_INTERN_H
|
#ifndef _LOCK_INTERN_H
|
||||||
#define _LOCK_INTERN_H
|
#define _LOCK_INTERN_H
|
||||||
@ -86,4 +86,11 @@ __mutex_unlock (void *__lock)
|
|||||||
__mutex_unlock_solid (__lock);
|
__mutex_unlock_solid (__lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_EXTERN_INLINE int
|
||||||
|
__mutex_trylock (void *__lock)
|
||||||
|
{
|
||||||
|
return __spin_try_lock ((__spin_lock_t *) __lock);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* lock-intern.h */
|
#endif /* lock-intern.h */
|
||||||
|
582
malloc/malloc.c
582
malloc/malloc.c
@ -19,7 +19,7 @@
|
|||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
/* VERSION 2.6.4-pt Wed Dec 4 00:35:54 MET 1996
|
/* V2.6.4-pt2 Sat Dec 14 1996
|
||||||
|
|
||||||
This work is mainly derived from malloc-2.6.4 by Doug Lea
|
This work is mainly derived from malloc-2.6.4 by Doug Lea
|
||||||
<dl@cs.oswego.edu>, which is available from:
|
<dl@cs.oswego.edu>, which is available from:
|
||||||
@ -53,7 +53,7 @@
|
|||||||
Initialize global configuration. When compiled for multiple threads,
|
Initialize global configuration. When compiled for multiple threads,
|
||||||
this function must be called once before any other function in the
|
this function must be called once before any other function in the
|
||||||
package. It is not required otherwise. It is called automatically
|
package. It is not required otherwise. It is called automatically
|
||||||
in the Linux/GNU C libray.
|
in the Linux/GNU C libray or when compiling with MALLOC_HOOKS.
|
||||||
malloc(size_t n);
|
malloc(size_t n);
|
||||||
Return a pointer to a newly allocated chunk of at least n bytes, or null
|
Return a pointer to a newly allocated chunk of at least n bytes, or null
|
||||||
if no space is available.
|
if no space is available.
|
||||||
@ -154,7 +154,6 @@
|
|||||||
|
|
||||||
Here are some features that are NOT currently supported
|
Here are some features that are NOT currently supported
|
||||||
|
|
||||||
* No user-definable hooks for callbacks and the like.
|
|
||||||
* No automated mechanism for fully checking that all accesses
|
* No automated mechanism for fully checking that all accesses
|
||||||
to malloced memory stay within their bounds.
|
to malloced memory stay within their bounds.
|
||||||
* No support for compaction.
|
* No support for compaction.
|
||||||
@ -180,6 +179,9 @@
|
|||||||
Define to enable debugging. Adds fairly extensive assertion-based
|
Define to enable debugging. Adds fairly extensive assertion-based
|
||||||
checking to help track down memory errors, but noticeably slows down
|
checking to help track down memory errors, but noticeably slows down
|
||||||
execution.
|
execution.
|
||||||
|
MALLOC_HOOKS (default: NOT defined)
|
||||||
|
Define to enable support run-time replacement of the allocation
|
||||||
|
functions through user-defined `hooks'.
|
||||||
REALLOC_ZERO_BYTES_FREES (default: NOT defined)
|
REALLOC_ZERO_BYTES_FREES (default: NOT defined)
|
||||||
Define this if you think that realloc(p, 0) should be equivalent
|
Define this if you think that realloc(p, 0) should be equivalent
|
||||||
to free(p). Otherwise, since malloc returns a unique pointer for
|
to free(p). Otherwise, since malloc returns a unique pointer for
|
||||||
@ -234,6 +236,10 @@
|
|||||||
These values may also be changed dynamically via mallopt(). The
|
These values may also be changed dynamically via mallopt(). The
|
||||||
preset defaults are those that give best performance for typical
|
preset defaults are those that give best performance for typical
|
||||||
programs/systems.
|
programs/systems.
|
||||||
|
DEFAULT_CHECK_ACTION
|
||||||
|
When the standard debugging hooks are in place, and a pointer is
|
||||||
|
detected as corrupt, do nothing (0), print an error message (1),
|
||||||
|
or call abort() (2).
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -291,6 +297,9 @@
|
|||||||
|
|
||||||
#if __STD_C
|
#if __STD_C
|
||||||
# include <stddef.h> /* for size_t */
|
# include <stddef.h> /* for size_t */
|
||||||
|
# if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
# include <stdlib.h> /* for getenv() */
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -306,6 +315,13 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdio.h> /* needed for malloc_stats */
|
#include <stdio.h> /* needed for malloc_stats */
|
||||||
|
|
||||||
|
/* We must not pollute the name space in the GNU libc. */
|
||||||
|
#ifdef _LIBC
|
||||||
|
#define malloc_stats __malloc_stats
|
||||||
|
#define malloc_usable_size __malloc_usable_size
|
||||||
|
#define malloc_trim __malloc_trim
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compile-time options
|
Compile-time options
|
||||||
@ -380,7 +396,7 @@ extern "C" {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define HAVE_MEMCPY
|
#define HAVE_MEMCPY 1
|
||||||
|
|
||||||
#ifndef USE_MEMCPY
|
#ifndef USE_MEMCPY
|
||||||
#ifdef HAVE_MEMCPY
|
#ifdef HAVE_MEMCPY
|
||||||
@ -768,6 +784,16 @@ do { \
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DEFAULT_CHECK_ACTION
|
||||||
|
#define DEFAULT_CHECK_ACTION 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* What to do if the standard debugging hooks are in place and a
|
||||||
|
corrupt pointer is detected: do nothing (0), print an error message
|
||||||
|
(1), or call abort() (2). */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define HEAP_MIN_SIZE (32*1024)
|
#define HEAP_MIN_SIZE (32*1024)
|
||||||
#define HEAP_MAX_SIZE (1024*1024) /* must be a power of two */
|
#define HEAP_MAX_SIZE (1024*1024) /* must be a power of two */
|
||||||
|
|
||||||
@ -813,6 +839,11 @@ static Void_t *(*__morecore)() = __default_morecore;
|
|||||||
#define MORECORE (*__morecore)
|
#define MORECORE (*__morecore)
|
||||||
#define MORECORE_FAILURE 0
|
#define MORECORE_FAILURE 0
|
||||||
#define MORECORE_CLEARS 1
|
#define MORECORE_CLEARS 1
|
||||||
|
#define mmap __mmap
|
||||||
|
#define munmap __munmap
|
||||||
|
#define mremap __mremap
|
||||||
|
#undef malloc_getpagesize
|
||||||
|
#define malloc_getpagesize __getpagesize()
|
||||||
|
|
||||||
#else /* _LIBC */
|
#else /* _LIBC */
|
||||||
|
|
||||||
@ -836,7 +867,7 @@ extern Void_t* sbrk();
|
|||||||
|
|
||||||
#endif /* _LIBC */
|
#endif /* _LIBC */
|
||||||
|
|
||||||
#if 0 && defined(_LIBC)
|
#ifdef _LIBC
|
||||||
|
|
||||||
#define cALLOc __libc_calloc
|
#define cALLOc __libc_calloc
|
||||||
#define fREe __libc_free
|
#define fREe __libc_free
|
||||||
@ -848,17 +879,6 @@ extern Void_t* sbrk();
|
|||||||
#define mALLINFo __libc_mallinfo
|
#define mALLINFo __libc_mallinfo
|
||||||
#define mALLOPt __libc_mallopt
|
#define mALLOPt __libc_mallopt
|
||||||
|
|
||||||
#pragma weak calloc = __libc_calloc
|
|
||||||
#pragma weak free = __libc_free
|
|
||||||
#pragma weak cfree = __libc_free
|
|
||||||
#pragma weak malloc = __libc_malloc
|
|
||||||
#pragma weak memalign = __libc_memalign
|
|
||||||
#pragma weak realloc = __libc_realloc
|
|
||||||
#pragma weak valloc = __libc_valloc
|
|
||||||
#pragma weak pvalloc = __libc_pvalloc
|
|
||||||
#pragma weak mallinfo = __libc_mallinfo
|
|
||||||
#pragma weak mallopt = __libc_mallopt
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define cALLOc calloc
|
#define cALLOc calloc
|
||||||
@ -888,8 +908,11 @@ Void_t* vALLOc(size_t);
|
|||||||
Void_t* pvALLOc(size_t);
|
Void_t* pvALLOc(size_t);
|
||||||
Void_t* cALLOc(size_t, size_t);
|
Void_t* cALLOc(size_t, size_t);
|
||||||
void cfree(Void_t*);
|
void cfree(Void_t*);
|
||||||
|
int __malloc_trim(size_t);
|
||||||
int malloc_trim(size_t);
|
int malloc_trim(size_t);
|
||||||
|
size_t __malloc_usable_size(Void_t*);
|
||||||
size_t malloc_usable_size(Void_t*);
|
size_t malloc_usable_size(Void_t*);
|
||||||
|
void __malloc_stats(void);
|
||||||
void malloc_stats(void);
|
void malloc_stats(void);
|
||||||
int mALLOPt(int, int);
|
int mALLOPt(int, int);
|
||||||
struct mallinfo mALLINFo(void);
|
struct mallinfo mALLINFo(void);
|
||||||
@ -905,8 +928,11 @@ Void_t* vALLOc();
|
|||||||
Void_t* pvALLOc();
|
Void_t* pvALLOc();
|
||||||
Void_t* cALLOc();
|
Void_t* cALLOc();
|
||||||
void cfree();
|
void cfree();
|
||||||
|
int __malloc_trim();
|
||||||
int malloc_trim();
|
int malloc_trim();
|
||||||
|
size_t _malloc_usable_size();
|
||||||
size_t malloc_usable_size();
|
size_t malloc_usable_size();
|
||||||
|
void __malloc_stats();
|
||||||
void malloc_stats();
|
void malloc_stats();
|
||||||
int mALLOPt();
|
int mALLOPt();
|
||||||
struct mallinfo mALLINFo();
|
struct mallinfo mALLINFo();
|
||||||
@ -1136,19 +1162,41 @@ typedef struct _heap_info {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if __STD_C
|
#if __STD_C
|
||||||
|
|
||||||
static void chunk_free(arena *ar_ptr, mchunkptr p);
|
static void chunk_free(arena *ar_ptr, mchunkptr p);
|
||||||
static mchunkptr chunk_alloc(arena *ar_ptr, INTERNAL_SIZE_T size);
|
static mchunkptr chunk_alloc(arena *ar_ptr, INTERNAL_SIZE_T size);
|
||||||
|
static mchunkptr chunk_realloc(arena *ar_ptr, mchunkptr oldp,
|
||||||
|
INTERNAL_SIZE_T oldsize, INTERNAL_SIZE_T nb);
|
||||||
|
static mchunkptr chunk_align(arena *ar_ptr, INTERNAL_SIZE_T nb,
|
||||||
|
size_t alignment);
|
||||||
static int main_trim(size_t pad);
|
static int main_trim(size_t pad);
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
static int heap_trim(heap_info *heap, size_t pad);
|
static int heap_trim(heap_info *heap, size_t pad);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
static Void_t* malloc_check(size_t sz);
|
||||||
|
static void free_check(Void_t* mem);
|
||||||
|
static Void_t* realloc_check(Void_t* oldmem, size_t bytes);
|
||||||
|
static Void_t* memalign_check(size_t alignment, size_t bytes);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static void chunk_free();
|
static void chunk_free();
|
||||||
static mchunkptr chunk_alloc();
|
static mchunkptr chunk_alloc();
|
||||||
|
static mchunkptr chunk_realloc();
|
||||||
|
static mchunkptr chunk_align();
|
||||||
static int main_trim();
|
static int main_trim();
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
static int heap_trim();
|
static int heap_trim();
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
static Void_t* malloc_check();
|
||||||
|
static void free_check();
|
||||||
|
static Void_t* realloc_check();
|
||||||
|
static Void_t* memalign_check();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -1416,6 +1464,7 @@ static unsigned long trim_threshold = DEFAULT_TRIM_THRESHOLD;
|
|||||||
static unsigned long top_pad = DEFAULT_TOP_PAD;
|
static unsigned long top_pad = DEFAULT_TOP_PAD;
|
||||||
static unsigned int n_mmaps_max = DEFAULT_MMAP_MAX;
|
static unsigned int n_mmaps_max = DEFAULT_MMAP_MAX;
|
||||||
static unsigned long mmap_threshold = DEFAULT_MMAP_THRESHOLD;
|
static unsigned long mmap_threshold = DEFAULT_MMAP_THRESHOLD;
|
||||||
|
static int check_action = DEFAULT_CHECK_ACTION;
|
||||||
|
|
||||||
/* The first value returned from sbrk */
|
/* The first value returned from sbrk */
|
||||||
static char* sbrk_base = (char*)(-1);
|
static char* sbrk_base = (char*)(-1);
|
||||||
@ -1444,7 +1493,9 @@ static unsigned long max_mmapped_mem = 0;
|
|||||||
|
|
||||||
/* Initialization routine. */
|
/* Initialization routine. */
|
||||||
#if defined(_LIBC)
|
#if defined(_LIBC)
|
||||||
|
#if 0
|
||||||
static void ptmalloc_init __MALLOC_P ((void)) __attribute__ ((constructor));
|
static void ptmalloc_init __MALLOC_P ((void)) __attribute__ ((constructor));
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ptmalloc_init __MALLOC_P((void))
|
ptmalloc_init __MALLOC_P((void))
|
||||||
@ -1454,24 +1505,103 @@ ptmalloc_init __MALLOC_P((void))
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
const char* s;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!first) return;
|
||||||
|
first = 0;
|
||||||
#if defined(_LIBC)
|
#if defined(_LIBC)
|
||||||
/* Initialize the pthreads interface. */
|
/* Initialize the pthreads interface. */
|
||||||
if (__pthread_initialize != NULL)
|
if (__pthread_initialize != NULL)
|
||||||
__pthread_initialize();
|
__pthread_initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(first) {
|
|
||||||
first = 0;
|
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
mutex_init(&main_arena.mutex);
|
mutex_init(&main_arena.mutex);
|
||||||
mutex_init(&list_lock);
|
mutex_init(&list_lock);
|
||||||
tsd_key_create(&arena_key, NULL);
|
tsd_key_create(&arena_key, NULL);
|
||||||
tsd_setspecific(arena_key, (Void_t *)&main_arena);
|
tsd_setspecific(arena_key, (Void_t *)&main_arena);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
s = getenv("MALLOC_CHECK_");
|
||||||
|
if(s) {
|
||||||
|
if(s[0]) mallopt(M_CHECK_ACTION, (int)(s[0] - '0'));
|
||||||
|
malloc_check_init();
|
||||||
}
|
}
|
||||||
|
if(__malloc_initialize_hook != NULL)
|
||||||
|
(*__malloc_initialize_hook)();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
|
||||||
|
/* Hooks for debugging versions. The initial hooks just call the
|
||||||
|
initialization routine, then do the normal work. */
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
malloc_hook_ini(size_t sz)
|
||||||
|
#else
|
||||||
|
malloc_hook_ini(sz) size_t sz;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
__malloc_hook = NULL;
|
||||||
|
__realloc_hook = NULL;
|
||||||
|
__memalign_hook = NULL;
|
||||||
|
ptmalloc_init();
|
||||||
|
return mALLOc(sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
realloc_hook_ini(Void_t* ptr, size_t sz)
|
||||||
|
#else
|
||||||
|
realloc_hook_ini(ptr, sz) Void_t* ptr; size_t sz;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
__malloc_hook = NULL;
|
||||||
|
__realloc_hook = NULL;
|
||||||
|
__memalign_hook = NULL;
|
||||||
|
ptmalloc_init();
|
||||||
|
return rEALLOc(ptr, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
memalign_hook_ini(size_t sz, size_t alignment)
|
||||||
|
#else
|
||||||
|
memalign_hook_ini(sz, alignment) size_t sz; size_t alignment;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
__malloc_hook = NULL;
|
||||||
|
__realloc_hook = NULL;
|
||||||
|
__memalign_hook = NULL;
|
||||||
|
ptmalloc_init();
|
||||||
|
return mEMALIGn(sz, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
void (*__malloc_initialize_hook) __MALLOC_P ((void)) = NULL;
|
||||||
|
void (*__free_hook) __MALLOC_P ((__malloc_ptr_t __ptr)) = NULL;
|
||||||
|
__malloc_ptr_t (*__malloc_hook)
|
||||||
|
__MALLOC_P ((size_t __size)) = malloc_hook_ini;
|
||||||
|
__malloc_ptr_t (*__realloc_hook)
|
||||||
|
__MALLOC_P ((__malloc_ptr_t __ptr, size_t __size)) = realloc_hook_ini;
|
||||||
|
__malloc_ptr_t (*__memalign_hook)
|
||||||
|
__MALLOC_P ((size_t __size, size_t __alignment)) = memalign_hook_ini;
|
||||||
|
|
||||||
|
/* Activate a standard set of debugging hooks. */
|
||||||
|
void
|
||||||
|
malloc_check_init()
|
||||||
|
{
|
||||||
|
__malloc_hook = malloc_check;
|
||||||
|
__free_hook = free_check;
|
||||||
|
__realloc_hook = realloc_check;
|
||||||
|
__memalign_hook = memalign_check;
|
||||||
|
fprintf(stderr, "Using debugging hooks\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2224,9 +2354,19 @@ Void_t* mALLOc(bytes) size_t bytes;
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
arena *ar_ptr;
|
arena *ar_ptr;
|
||||||
INTERNAL_SIZE_T nb = request2size(bytes); /* padded request size; */
|
INTERNAL_SIZE_T nb; /* padded request size */
|
||||||
mchunkptr victim;
|
mchunkptr victim;
|
||||||
|
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
if (__malloc_hook != NULL) {
|
||||||
|
Void_t* result;
|
||||||
|
|
||||||
|
result = (*__malloc_hook)(bytes);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nb = request2size(bytes);
|
||||||
arena_get(ar_ptr, nb + top_pad);
|
arena_get(ar_ptr, nb + top_pad);
|
||||||
if(!ar_ptr)
|
if(!ar_ptr)
|
||||||
return 0;
|
return 0;
|
||||||
@ -2501,6 +2641,13 @@ void fREe(mem) Void_t* mem;
|
|||||||
arena *ar_ptr;
|
arena *ar_ptr;
|
||||||
mchunkptr p; /* chunk corresponding to mem */
|
mchunkptr p; /* chunk corresponding to mem */
|
||||||
|
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
if (__free_hook != NULL) {
|
||||||
|
(*__free_hook)(mem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mem == 0) /* free(0) has no effect */
|
if (mem == 0) /* free(0) has no effect */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2676,38 +2823,33 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
INTERNAL_SIZE_T oldsize; /* its size */
|
INTERNAL_SIZE_T oldsize; /* its size */
|
||||||
|
|
||||||
mchunkptr newp; /* chunk to return */
|
mchunkptr newp; /* chunk to return */
|
||||||
INTERNAL_SIZE_T newsize; /* its size */
|
|
||||||
Void_t* newmem; /* corresponding user mem */
|
|
||||||
|
|
||||||
mchunkptr next; /* next contiguous chunk after oldp */
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
INTERNAL_SIZE_T nextsize; /* its size */
|
if (__realloc_hook != NULL) {
|
||||||
|
Void_t* result;
|
||||||
|
|
||||||
mchunkptr prev; /* previous contiguous chunk before oldp */
|
result = (*__realloc_hook)(oldmem, bytes);
|
||||||
INTERNAL_SIZE_T prevsize; /* its size */
|
return result;
|
||||||
|
}
|
||||||
mchunkptr remainder; /* holds split off extra space from newp */
|
#endif
|
||||||
INTERNAL_SIZE_T remainder_size; /* its size */
|
|
||||||
|
|
||||||
mchunkptr bck; /* misc temp for linking */
|
|
||||||
mchunkptr fwd; /* misc temp for linking */
|
|
||||||
|
|
||||||
#ifdef REALLOC_ZERO_BYTES_FREES
|
#ifdef REALLOC_ZERO_BYTES_FREES
|
||||||
if (bytes == 0) { fREe(oldmem); return 0; }
|
if (bytes == 0) { fREe(oldmem); return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* realloc of null is supposed to be same as malloc */
|
/* realloc of null is supposed to be same as malloc */
|
||||||
if (oldmem == 0) return mALLOc(bytes);
|
if (oldmem == 0) return mALLOc(bytes);
|
||||||
|
|
||||||
newp = oldp = mem2chunk(oldmem);
|
oldp = mem2chunk(oldmem);
|
||||||
newsize = oldsize = chunksize(oldp);
|
oldsize = chunksize(oldp);
|
||||||
|
|
||||||
|
|
||||||
nb = request2size(bytes);
|
nb = request2size(bytes);
|
||||||
|
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
if (chunk_is_mmapped(oldp))
|
if (chunk_is_mmapped(oldp))
|
||||||
{
|
{
|
||||||
|
Void_t* newmem;
|
||||||
|
|
||||||
#if HAVE_MREMAP
|
#if HAVE_MREMAP
|
||||||
newp = mremap_chunk(oldp, nb);
|
newp = mremap_chunk(oldp, nb);
|
||||||
if(newp) return chunk2mem(newp);
|
if(newp) return chunk2mem(newp);
|
||||||
@ -2738,6 +2880,36 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
/* As in malloc(), remember this arena for the next allocation. */
|
/* As in malloc(), remember this arena for the next allocation. */
|
||||||
tsd_setspecific(arena_key, (Void_t *)ar_ptr);
|
tsd_setspecific(arena_key, (Void_t *)ar_ptr);
|
||||||
|
|
||||||
|
newp = chunk_realloc(ar_ptr, oldp, oldsize, nb);
|
||||||
|
|
||||||
|
(void)mutex_unlock(&ar_ptr->mutex);
|
||||||
|
return newp ? chunk2mem(newp) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mchunkptr
|
||||||
|
#if __STD_C
|
||||||
|
chunk_realloc(arena* ar_ptr, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
|
||||||
|
INTERNAL_SIZE_T nb)
|
||||||
|
#else
|
||||||
|
chunk_realloc(ar_ptr, oldp, oldsize, nb)
|
||||||
|
arena* ar_ptr; mchunkptr oldp; INTERNAL_SIZE_T oldsize, nb;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mchunkptr newp = oldp; /* chunk to return */
|
||||||
|
INTERNAL_SIZE_T newsize = oldsize; /* its size */
|
||||||
|
|
||||||
|
mchunkptr next; /* next contiguous chunk after oldp */
|
||||||
|
INTERNAL_SIZE_T nextsize; /* its size */
|
||||||
|
|
||||||
|
mchunkptr prev; /* previous contiguous chunk before oldp */
|
||||||
|
INTERNAL_SIZE_T prevsize; /* its size */
|
||||||
|
|
||||||
|
mchunkptr remainder; /* holds split off extra space from newp */
|
||||||
|
INTERNAL_SIZE_T remainder_size; /* its size */
|
||||||
|
|
||||||
|
mchunkptr bck; /* misc temp for linking */
|
||||||
|
mchunkptr fwd; /* misc temp for linking */
|
||||||
|
|
||||||
check_inuse_chunk(ar_ptr, oldp);
|
check_inuse_chunk(ar_ptr, oldp);
|
||||||
|
|
||||||
if ((long)(oldsize) < (long)(nb))
|
if ((long)(oldsize) < (long)(nb))
|
||||||
@ -2759,8 +2931,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
top(ar_ptr) = chunk_at_offset(oldp, nb);
|
top(ar_ptr) = chunk_at_offset(oldp, nb);
|
||||||
set_head(top(ar_ptr), (newsize - nb) | PREV_INUSE);
|
set_head(top(ar_ptr), (newsize - nb) | PREV_INUSE);
|
||||||
set_head_size(oldp, nb);
|
set_head_size(oldp, nb);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return oldp;
|
||||||
return chunk2mem(oldp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2797,13 +2968,11 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += prevsize + nextsize;
|
newsize += prevsize + nextsize;
|
||||||
newmem = chunk2mem(newp);
|
MALLOC_COPY(chunk2mem(newp), chunk2mem(oldp), oldsize - SIZE_SZ);
|
||||||
MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
|
|
||||||
top(ar_ptr) = chunk_at_offset(newp, nb);
|
top(ar_ptr) = chunk_at_offset(newp, nb);
|
||||||
set_head(top(ar_ptr), (newsize - nb) | PREV_INUSE);
|
set_head(top(ar_ptr), (newsize - nb) | PREV_INUSE);
|
||||||
set_head_size(newp, nb);
|
set_head_size(newp, nb);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return newp;
|
||||||
return newmem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2814,8 +2983,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += nextsize + prevsize;
|
newsize += nextsize + prevsize;
|
||||||
newmem = chunk2mem(newp);
|
MALLOC_COPY(chunk2mem(newp), chunk2mem(oldp), oldsize - SIZE_SZ);
|
||||||
MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
|
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2826,8 +2994,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
unlink(prev, bck, fwd);
|
unlink(prev, bck, fwd);
|
||||||
newp = prev;
|
newp = prev;
|
||||||
newsize += prevsize;
|
newsize += prevsize;
|
||||||
newmem = chunk2mem(newp);
|
MALLOC_COPY(chunk2mem(newp), chunk2mem(oldp), oldsize - SIZE_SZ);
|
||||||
MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
|
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2850,11 +3017,9 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise copy, free, and exit */
|
/* Otherwise copy, free, and exit */
|
||||||
newmem = chunk2mem(newp);
|
MALLOC_COPY(chunk2mem(newp), chunk2mem(oldp), oldsize - SIZE_SZ);
|
||||||
MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
|
|
||||||
chunk_free(ar_ptr, oldp);
|
chunk_free(ar_ptr, oldp);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return newp;
|
||||||
return newmem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2876,8 +3041,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_inuse_chunk(ar_ptr, newp);
|
check_inuse_chunk(ar_ptr, newp);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return newp;
|
||||||
return chunk2mem(newp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2910,14 +3074,16 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
|
|||||||
{
|
{
|
||||||
arena *ar_ptr;
|
arena *ar_ptr;
|
||||||
INTERNAL_SIZE_T nb; /* padded request size */
|
INTERNAL_SIZE_T nb; /* padded request size */
|
||||||
char* m; /* memory returned by malloc call */
|
mchunkptr p;
|
||||||
mchunkptr p; /* corresponding chunk */
|
|
||||||
char* brk; /* alignment point within p */
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
mchunkptr newp; /* chunk to return */
|
if (__memalign_hook != NULL) {
|
||||||
INTERNAL_SIZE_T newsize; /* its size */
|
Void_t* result;
|
||||||
INTERNAL_SIZE_T leadsize; /* leading space befor alignment point */
|
|
||||||
mchunkptr remainder; /* spare room at end to split off */
|
result = (*__memalign_hook)(alignment, bytes);
|
||||||
long remainder_size; /* its size */
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If need less alignment than we give anyway, just relay to malloc */
|
/* If need less alignment than we give anyway, just relay to malloc */
|
||||||
|
|
||||||
@ -2927,27 +3093,44 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
|
|||||||
|
|
||||||
if (alignment < MINSIZE) alignment = MINSIZE;
|
if (alignment < MINSIZE) alignment = MINSIZE;
|
||||||
|
|
||||||
/* Call malloc with worst case padding to hit alignment. */
|
|
||||||
|
|
||||||
nb = request2size(bytes);
|
nb = request2size(bytes);
|
||||||
arena_get(ar_ptr, nb + alignment + MINSIZE);
|
arena_get(ar_ptr, nb + alignment + MINSIZE);
|
||||||
if(!ar_ptr)
|
if(!ar_ptr)
|
||||||
return 0;
|
return 0;
|
||||||
p = chunk_alloc(ar_ptr, nb + alignment + MINSIZE);
|
p = chunk_align(ar_ptr, nb, alignment);
|
||||||
|
|
||||||
if (p == 0) {
|
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
(void)mutex_unlock(&ar_ptr->mutex);
|
||||||
return 0; /* propagate failure */
|
return p ? chunk2mem(p) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static mchunkptr
|
||||||
|
#if __STD_C
|
||||||
|
chunk_align(arena* ar_ptr, INTERNAL_SIZE_T nb, size_t alignment)
|
||||||
|
#else
|
||||||
|
chunk_align(ar_ptr, nb, alignment)
|
||||||
|
arena* ar_ptr; INTERNAL_SIZE_T nb; size_t alignment;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
char* m; /* memory returned by malloc call */
|
||||||
|
mchunkptr p; /* corresponding chunk */
|
||||||
|
char* brk; /* alignment point within p */
|
||||||
|
mchunkptr newp; /* chunk to return */
|
||||||
|
INTERNAL_SIZE_T newsize; /* its size */
|
||||||
|
INTERNAL_SIZE_T leadsize; /* leading space befor alignment point */
|
||||||
|
mchunkptr remainder; /* spare room at end to split off */
|
||||||
|
long remainder_size; /* its size */
|
||||||
|
|
||||||
|
/* Call chunk_alloc with worst case padding to hit alignment. */
|
||||||
|
p = chunk_alloc(ar_ptr, nb + alignment + MINSIZE);
|
||||||
|
if (p == 0)
|
||||||
|
return 0; /* propagate failure */
|
||||||
|
|
||||||
m = chunk2mem(p);
|
m = chunk2mem(p);
|
||||||
|
|
||||||
if ((((unsigned long)(m)) % alignment) == 0) /* aligned */
|
if ((((unsigned long)(m)) % alignment) == 0) /* aligned */
|
||||||
{
|
{
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
if(chunk_is_mmapped(p)) {
|
if(chunk_is_mmapped(p)) {
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return p; /* nothing more to do */
|
||||||
return chunk2mem(p); /* nothing more to do */
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2963,7 +3146,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
brk = (char*)mem2chunk(((unsigned long)(m + alignment - 1)) & -alignment);
|
brk = (char*)mem2chunk(((unsigned long)(m + alignment - 1)) & -alignment);
|
||||||
if ((long)(brk - (char*)(p)) < (long)MINSIZE) brk = brk + alignment;
|
if ((long)(brk - (char*)(p)) < (long)MINSIZE) brk += alignment;
|
||||||
|
|
||||||
newp = (mchunkptr)brk;
|
newp = (mchunkptr)brk;
|
||||||
leadsize = brk - (char*)(p);
|
leadsize = brk - (char*)(p);
|
||||||
@ -2974,8 +3157,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
|
|||||||
{
|
{
|
||||||
newp->prev_size = p->prev_size + leadsize;
|
newp->prev_size = p->prev_size + leadsize;
|
||||||
set_head(newp, newsize|IS_MMAPPED);
|
set_head(newp, newsize|IS_MMAPPED);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return newp;
|
||||||
return chunk2mem(newp);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3003,9 +3185,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_inuse_chunk(ar_ptr, p);
|
check_inuse_chunk(ar_ptr, p);
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
return p;
|
||||||
return chunk2mem(p);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3044,7 +3224,7 @@ Void_t* pvALLOc(bytes) size_t bytes;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
calloc calls malloc, then zeroes out the allocated chunk.
|
calloc calls chunk_alloc, then zeroes out the allocated chunk.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -3056,11 +3236,23 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
|
|||||||
{
|
{
|
||||||
arena *ar_ptr;
|
arena *ar_ptr;
|
||||||
mchunkptr p, oldtop;
|
mchunkptr p, oldtop;
|
||||||
INTERNAL_SIZE_T csz, oldtopsize;
|
INTERNAL_SIZE_T sz, csz, oldtopsize;
|
||||||
Void_t* mem;
|
Void_t* mem;
|
||||||
|
|
||||||
INTERNAL_SIZE_T sz = request2size(n * elem_size);
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
if (__malloc_hook != NULL) {
|
||||||
|
sz = n * elem_size;
|
||||||
|
mem = (*__malloc_hook)(sz);
|
||||||
|
#ifdef HAVE_MEMCPY
|
||||||
|
memset(mem, 0, sz);
|
||||||
|
#else
|
||||||
|
while(sz > 0) mem[--sz] = 0; /* rather inefficient */
|
||||||
|
#endif
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sz = request2size(n * elem_size);
|
||||||
arena_get(ar_ptr, sz);
|
arena_get(ar_ptr, sz);
|
||||||
if(!ar_ptr)
|
if(!ar_ptr)
|
||||||
return 0;
|
return 0;
|
||||||
@ -3232,7 +3424,7 @@ heap_trim(heap, pad) heap_info *heap; size_t pad;
|
|||||||
assert(p->size == (0|PREV_INUSE)); /* must be fencepost */
|
assert(p->size == (0|PREV_INUSE)); /* must be fencepost */
|
||||||
p = prev_chunk(p);
|
p = prev_chunk(p);
|
||||||
new_size = chunksize(p) + (MINSIZE-2*SIZE_SZ);
|
new_size = chunksize(p) + (MINSIZE-2*SIZE_SZ);
|
||||||
assert(new_size>0 && new_size<(long int)(2*MINSIZE));
|
assert(new_size>0 && new_size<(long)(2*MINSIZE));
|
||||||
if(!prev_inuse(p))
|
if(!prev_inuse(p))
|
||||||
new_size += p->prev_size;
|
new_size += p->prev_size;
|
||||||
assert(new_size>0 && new_size<HEAP_MAX_SIZE);
|
assert(new_size>0 && new_size<HEAP_MAX_SIZE);
|
||||||
@ -3513,29 +3705,241 @@ int mALLOPt(param_number, value) int param_number; int value;
|
|||||||
#else
|
#else
|
||||||
if (value != 0) return 0; else n_mmaps_max = value; return 1;
|
if (value != 0) return 0; else n_mmaps_max = value; return 1;
|
||||||
#endif
|
#endif
|
||||||
|
case M_CHECK_ACTION:
|
||||||
|
check_action = value; return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
weak_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc)
|
||||||
|
weak_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree)
|
||||||
|
weak_alias (__libc_free, __free) weak_alias (__libc_free, free)
|
||||||
|
weak_alias (__libc_malloc, __malloc) weak_alias (__libc_malloc, malloc)
|
||||||
|
weak_alias (__libc_memalign, __memalign) weak_alias (__libc_memalign, memalign)
|
||||||
|
weak_alias (__libc_realloc, __realloc) weak_alias (__libc_realloc, realloc)
|
||||||
|
weak_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc)
|
||||||
|
weak_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc)
|
||||||
|
weak_alias (__libc_mallinfo, __mallinfo) weak_alias (__libc_mallinfo, mallinfo)
|
||||||
|
weak_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
|
||||||
|
|
||||||
#if 0 && defined(_LIBC)
|
#undef malloc_stats
|
||||||
weak_alias (__libc_calloc, calloc)
|
weak_alias (__malloc_stats, malloc_stats)
|
||||||
weak_alias (__libc_free, cfree)
|
#undef malloc_usable_size
|
||||||
weak_alias (__libc_free, free)
|
weak_alias (__malloc_usable_size, malloc_usable_size)
|
||||||
weak_alias (__libc_malloc, malloc)
|
#undef malloc_trim
|
||||||
weak_alias (__libc_memalign, memalign)
|
weak_alias (__malloc_trim, malloc_trim)
|
||||||
weak_alias (__libc_realloc, realloc)
|
|
||||||
weak_alias (__libc_valloc, valloc)
|
|
||||||
weak_alias (__libc_pvalloc, pvalloc)
|
|
||||||
weak_alias (__libc_mallinfo, mallinfo)
|
|
||||||
weak_alias (__libc_mallopt, mallopt)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_LIBC) || defined(MALLOC_HOOKS)
|
||||||
|
|
||||||
|
/* A simple, standard set of debugging hooks. Overhead is `only' one
|
||||||
|
byte per chunk; still this will catch most cases of double frees or
|
||||||
|
overruns. */
|
||||||
|
|
||||||
|
#define MAGICBYTE ((char)0xd7)
|
||||||
|
|
||||||
|
/* Convert a pointer to be free()d or realloc()ed to a valid chunk
|
||||||
|
pointer. If the provided pointer is not valid, return NULL. The
|
||||||
|
goal here is to avoid crashes, unlike in the MALLOC_DEBUG code. */
|
||||||
|
|
||||||
|
static mchunkptr
|
||||||
|
#if __STD_C
|
||||||
|
mem2chunk_check(Void_t* mem)
|
||||||
|
#else
|
||||||
|
mem2chunk_check(mem) Void_t* mem;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mchunkptr p;
|
||||||
|
INTERNAL_SIZE_T sz;
|
||||||
|
|
||||||
|
p = mem2chunk(mem);
|
||||||
|
if(!aligned_OK(p)) return NULL;
|
||||||
|
if( (char*)p>=sbrk_base && (char*)p<(sbrk_base+sbrked_mem) ) {
|
||||||
|
/* Must be a chunk in conventional memory. */
|
||||||
|
if(chunk_is_mmapped(p) ||
|
||||||
|
( (sz = chunksize(p)), ((char*)p + sz)>=(sbrk_base+sbrked_mem) ) ||
|
||||||
|
sz<MINSIZE || sz&MALLOC_ALIGN_MASK || !inuse(p) ) return NULL;
|
||||||
|
if(*((char*)p + sz + (SIZE_SZ-1)) != MAGICBYTE) return NULL;
|
||||||
|
*((char*)p + sz + (SIZE_SZ-1)) = 0;
|
||||||
|
} else {
|
||||||
|
unsigned long offset, page_mask = malloc_getpagesize-1;
|
||||||
|
|
||||||
|
/* mmap()ed chunks have MALLOC_ALIGNMENT or higher power-of two
|
||||||
|
alignment relative to the beginning of a page. Check this
|
||||||
|
first. */
|
||||||
|
offset = (unsigned long)mem & page_mask;
|
||||||
|
if((offset!=MALLOC_ALIGNMENT && offset!=0 && offset!=0x10 &&
|
||||||
|
offset!=0x20 && offset!=0x40 && offset!=0x80 && offset!=0x100 &&
|
||||||
|
offset!=0x200 && offset!=0x400 && offset!=0x800 && offset!=0x1000 &&
|
||||||
|
offset<0x2000) ||
|
||||||
|
!chunk_is_mmapped(p) || (p->size & PREV_INUSE) ||
|
||||||
|
( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) ||
|
||||||
|
( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) )
|
||||||
|
return NULL;
|
||||||
|
if(*((char*)p + sz - 1) != MAGICBYTE) return NULL;
|
||||||
|
*((char*)p + sz - 1) = 0;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
malloc_check(size_t sz)
|
||||||
|
#else
|
||||||
|
malloc_check(sz) size_t sz;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mchunkptr victim;
|
||||||
|
INTERNAL_SIZE_T nb = request2size(sz + 1);
|
||||||
|
|
||||||
|
(void)mutex_lock(&main_arena.mutex);
|
||||||
|
victim = chunk_alloc(&main_arena, nb);
|
||||||
|
(void)mutex_unlock(&main_arena.mutex);
|
||||||
|
if(!victim) return NULL;
|
||||||
|
nb = chunksize(victim);
|
||||||
|
if(chunk_is_mmapped(victim))
|
||||||
|
--nb;
|
||||||
|
else
|
||||||
|
nb += SIZE_SZ - 1;
|
||||||
|
*((char*)victim + nb) = MAGICBYTE;
|
||||||
|
return chunk2mem(victim);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
#if __STD_C
|
||||||
|
free_check(Void_t* mem)
|
||||||
|
#else
|
||||||
|
free_check(mem) Void_t* mem;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mchunkptr p;
|
||||||
|
|
||||||
|
if(!mem) return;
|
||||||
|
p = mem2chunk_check(mem);
|
||||||
|
if(!p) {
|
||||||
|
switch(check_action) {
|
||||||
|
case 1:
|
||||||
|
fprintf(stderr, "free(): invalid pointer %lx!\n", (long)(mem));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if HAVE_MMAP
|
||||||
|
if (chunk_is_mmapped(p)) {
|
||||||
|
munmap_chunk(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
(void)mutex_lock(&main_arena.mutex);
|
||||||
|
chunk_free(&main_arena, p);
|
||||||
|
(void)mutex_unlock(&main_arena.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
realloc_check(Void_t* oldmem, size_t bytes)
|
||||||
|
#else
|
||||||
|
realloc_check(oldmem, bytes) Void_t* oldmem; size_t bytes;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mchunkptr oldp, newp;
|
||||||
|
INTERNAL_SIZE_T nb, oldsize;
|
||||||
|
|
||||||
|
if (oldmem == 0) return malloc_check(bytes);
|
||||||
|
oldp = mem2chunk_check(oldmem);
|
||||||
|
if(!oldp) {
|
||||||
|
switch(check_action) {
|
||||||
|
case 1:
|
||||||
|
fprintf(stderr, "realloc(): invalid pointer %lx!\n", (long)(oldmem));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return malloc_check(bytes);
|
||||||
|
}
|
||||||
|
oldsize = chunksize(oldp);
|
||||||
|
|
||||||
|
nb = request2size(bytes+1);
|
||||||
|
|
||||||
|
(void)mutex_lock(&main_arena.mutex);
|
||||||
|
#if HAVE_MMAP
|
||||||
|
if (chunk_is_mmapped(oldp)) {
|
||||||
|
#if HAVE_MREMAP
|
||||||
|
newp = mremap_chunk(oldp, nb);
|
||||||
|
if(!newp) {
|
||||||
|
#endif
|
||||||
|
/* Note the extra SIZE_SZ overhead. */
|
||||||
|
if(oldsize - SIZE_SZ >= nb) newp = oldp; /* do nothing */
|
||||||
|
else {
|
||||||
|
/* Must alloc, copy, free. */
|
||||||
|
newp = chunk_alloc(&main_arena, nb);
|
||||||
|
if (newp) {
|
||||||
|
MALLOC_COPY(chunk2mem(newp), oldmem, oldsize - 2*SIZE_SZ);
|
||||||
|
munmap_chunk(oldp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if HAVE_MREMAP
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
#endif /* HAVE_MMAP */
|
||||||
|
newp = chunk_realloc(&main_arena, oldp, oldsize, nb);
|
||||||
|
(void)mutex_unlock(&main_arena.mutex);
|
||||||
|
|
||||||
|
if(!newp) return NULL;
|
||||||
|
nb = chunksize(newp);
|
||||||
|
if(chunk_is_mmapped(newp))
|
||||||
|
--nb;
|
||||||
|
else
|
||||||
|
nb += SIZE_SZ - 1;
|
||||||
|
*((char*)newp + nb) = MAGICBYTE;
|
||||||
|
return chunk2mem(newp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Void_t*
|
||||||
|
#if __STD_C
|
||||||
|
memalign_check(size_t alignment, size_t bytes)
|
||||||
|
#else
|
||||||
|
memalign_check(alignment, bytes) size_t alignment; size_t bytes;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
INTERNAL_SIZE_T nb;
|
||||||
|
mchunkptr p;
|
||||||
|
|
||||||
|
if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes);
|
||||||
|
if (alignment < MINSIZE) alignment = MINSIZE;
|
||||||
|
|
||||||
|
nb = request2size(bytes+1);
|
||||||
|
(void)mutex_lock(&main_arena.mutex);
|
||||||
|
p = chunk_align(&main_arena, nb, alignment);
|
||||||
|
(void)mutex_unlock(&main_arena.mutex);
|
||||||
|
if(!p) return NULL;
|
||||||
|
nb = chunksize(p);
|
||||||
|
if(chunk_is_mmapped(p))
|
||||||
|
--nb;
|
||||||
|
else
|
||||||
|
nb += SIZE_SZ - 1;
|
||||||
|
*((char*)p + nb) = MAGICBYTE;
|
||||||
|
return chunk2mem(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* defined(_LIBC) || defined(MALLOC_HOOKS) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
History:
|
History:
|
||||||
|
|
||||||
|
V2.6.4-pt2 Sat Dec 14 1996 Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
|
||||||
|
* Added debugging hooks
|
||||||
|
* Fixed possible deadlock in realloc() when out of memory
|
||||||
|
* Don't pollute namespace in glibc: use __getpagesize, __mmap, etc.
|
||||||
|
|
||||||
V2.6.4-pt Wed Dec 4 1996 Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
|
V2.6.4-pt Wed Dec 4 1996 Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
|
||||||
* Very minor updates from the released 2.6.4 version.
|
* Very minor updates from the released 2.6.4 version.
|
||||||
* Trimmed include file down to exported data structures.
|
* Trimmed include file down to exported data structures.
|
||||||
|
@ -147,6 +147,7 @@ extern struct mallinfo mallinfo __MALLOC_P ((void));
|
|||||||
#define M_TOP_PAD -2
|
#define M_TOP_PAD -2
|
||||||
#define M_MMAP_THRESHOLD -3
|
#define M_MMAP_THRESHOLD -3
|
||||||
#define M_MMAP_MAX -4
|
#define M_MMAP_MAX -4
|
||||||
|
#define M_CHECK_ACTION -5
|
||||||
|
|
||||||
/* General SVID/XPG interface to tunable parameters. */
|
/* General SVID/XPG interface to tunable parameters. */
|
||||||
extern int mallopt __MALLOC_P ((int __param, int __val));
|
extern int mallopt __MALLOC_P ((int __param, int __val));
|
||||||
@ -162,6 +163,22 @@ extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr));
|
|||||||
/* Prints brief summary statistics on stderr. */
|
/* Prints brief summary statistics on stderr. */
|
||||||
extern void malloc_stats __MALLOC_P ((void));
|
extern void malloc_stats __MALLOC_P ((void));
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) || defined(MALLOC_HOOKS)
|
||||||
|
|
||||||
|
/* Hooks for debugging versions. */
|
||||||
|
extern void (*__malloc_initialize_hook) __MALLOC_P ((void));
|
||||||
|
extern void (*__free_hook) __MALLOC_P ((__malloc_ptr_t __ptr));
|
||||||
|
extern __malloc_ptr_t (*__malloc_hook) __MALLOC_P ((size_t __size));
|
||||||
|
extern __malloc_ptr_t (*__realloc_hook) __MALLOC_P ((__malloc_ptr_t __ptr,
|
||||||
|
size_t __size));
|
||||||
|
extern __malloc_ptr_t (*__memalign_hook) __MALLOC_P ((size_t __size,
|
||||||
|
size_t __alignment));
|
||||||
|
|
||||||
|
/* Activate a standard set of debugging hooks. */
|
||||||
|
extern void malloc_check_init __MALLOC_P ((void));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}; /* end of extern "C" */
|
}; /* end of extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
@ -267,20 +267,25 @@ For the @code{hosts} and @code{network} databases the default value is
|
|||||||
the DNS service not to be available but if it is available the answer it
|
the DNS service not to be available but if it is available the answer it
|
||||||
returns is ultimative.
|
returns is ultimative.
|
||||||
|
|
||||||
|
The @code{passwd}, @code{group}, and @code{shadow} databases are
|
||||||
|
traditionally handled in a special way. The appropriate files in the
|
||||||
|
@file{/etc} directory are read but if an entry with a name starting
|
||||||
|
with a @code{+} character is found NIS is used. This kind of lookup
|
||||||
|
remains possible by using the special lookup service @code{compat}
|
||||||
|
and the default value for the three databases above is
|
||||||
|
@code{compat [NOTFOUND=return] files}.
|
||||||
|
|
||||||
For all other databases the default value is
|
For all other databases the default value is
|
||||||
@code{compat [NOTFOUND=return] files}. This solution give the best
|
@code{nis [NOTFOUND=return] files}. This solution give the best
|
||||||
chance to be correct since NIS and file based lookup is used. The
|
chance to be correct since NIS and file based lookup is used.
|
||||||
@code{compat} service is available in a separate add-on to GNU C
|
|
||||||
library, available in the same place you got the GNU C library source
|
|
||||||
from.
|
|
||||||
|
|
||||||
@cindex optimizing NSS
|
@cindex optimizing NSS
|
||||||
A second point is that the user should try to optimize the lookup
|
A second point is that the user should try to optimize the lookup
|
||||||
process. The different service have different response times. A simple
|
process. The different service have different response times.
|
||||||
file look up on a local file could be fast, but if the file is long and the
|
A simple file look up on a local file could be fast, but if the file
|
||||||
needed entry is near the end of the file this may take quite some time.
|
is long and the needed entry is near the end of the file this may take
|
||||||
In this case it might be better to use the @code{db} service which
|
quite some time. In this case it might be better to use the @code{db}
|
||||||
allows fast local access to large data sets.
|
service which allows fast local access to large data sets.
|
||||||
|
|
||||||
Often the situation is that some global information like NIS must be
|
Often the situation is that some global information like NIS must be
|
||||||
used. So it is unavoidable to use service entries like @code{nis} etc.
|
used. So it is unavoidable to use service entries like @code{nis} etc.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%% TeX macros to handle Texinfo files.
|
%% TeX macros to handle Texinfo files.
|
||||||
%% $Id: texinfo.tex,v 2.194 1996/12/17 06:25:17 eggert Exp $
|
%% $Id: texinfo.tex,v 2.195 1996/12/18 03:22:53 drepper Exp $
|
||||||
|
|
||||||
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
|
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
|
||||||
% 94, 95, 1996 Free Software Foundation, Inc.
|
% 94, 95, 1996 Free Software Foundation, Inc.
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
% This automatically updates the version number based on RCS.
|
% This automatically updates the version number based on RCS.
|
||||||
\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
|
\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
|
||||||
\deftexinfoversion$Revision: 2.194 $
|
\deftexinfoversion$Revision: 2.195 $
|
||||||
\message{Loading texinfo package [Version \texinfoversion]:}
|
\message{Loading texinfo package [Version \texinfoversion]:}
|
||||||
|
|
||||||
% If in a .fmt file, print the version number
|
% If in a .fmt file, print the version number
|
||||||
|
@ -42,7 +42,6 @@ static char __ypdomainname[MAXHOSTNAMELEN + 1] = "\0";
|
|||||||
__libc_lock_define_initialized (static, ypbindlist_lock)
|
__libc_lock_define_initialized (static, ypbindlist_lock)
|
||||||
static dom_binding *__ypbindlist = NULL;
|
static dom_binding *__ypbindlist = NULL;
|
||||||
|
|
||||||
extern void xdr_free (xdrproc_t proc, char *objp);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__yp_bind (const char *domain, dom_binding ** ypdb)
|
__yp_bind (const char *domain, dom_binding ** ypdb)
|
||||||
|
@ -13,10 +13,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#define DATABASE_NAME group
|
#define DATABASE_NAME group
|
||||||
|
#define DEFAULT_CONFIG "compat [NOTFOUND=return] files"
|
||||||
|
|
||||||
#include "XXX-lookup.c"
|
#include "XXX-lookup.c"
|
||||||
|
@ -13,11 +13,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#define DATABASE_NAME networks
|
#define DATABASE_NAME networks
|
||||||
#define DEFAULT_CONFIG "dns files"
|
#define DEFAULT_CONFIG "dns [!UNAVAIL=return] files"
|
||||||
|
|
||||||
#include "XXX-lookup.c"
|
#include "XXX-lookup.c"
|
||||||
|
@ -119,7 +119,7 @@ __nss_database_lookup (const char *database, const char *alternate_name,
|
|||||||
or null to use the most common default. */
|
or null to use the most common default. */
|
||||||
if (*ni == NULL)
|
if (*ni == NULL)
|
||||||
*ni = nss_parse_service_list (defconfig
|
*ni = nss_parse_service_list (defconfig
|
||||||
?: "compat [NOTFOUND=return] files");
|
?: "nis [NOTFOUND=return] files");
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
|
@ -13,10 +13,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#define DATABASE_NAME passwd
|
#define DATABASE_NAME passwd
|
||||||
|
#define DEFAULT_CONFIG "compat [NOTFOUND=return] files"
|
||||||
|
|
||||||
#include "XXX-lookup.c"
|
#include "XXX-lookup.c"
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
|
|
||||||
#define DATABASE_NAME shadow
|
#define DATABASE_NAME shadow
|
||||||
#define ALTERNATE_NAME passwd
|
#define ALTERNATE_NAME passwd
|
||||||
|
#define DEFAULT_CONFIG "compat [NOTFOUND=return] files"
|
||||||
|
|
||||||
#include "XXX-lookup.c"
|
#include "XXX-lookup.c"
|
||||||
|
22
posix/glob.c
22
posix/glob.c
@ -843,24 +843,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
|||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct dirent dirbuf, *d;
|
struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ?
|
||||||
int success;
|
(*pglob->gl_readdir) (stream) :
|
||||||
|
readdir ((DIR *) stream));
|
||||||
if (flags & GLOB_ALTDIRFUNC)
|
if (d == NULL)
|
||||||
{
|
|
||||||
d = (*pglob->gl_readdir) (stream);
|
|
||||||
success = d != NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if defined HAVE_READDIR_R || defined _LIBC
|
|
||||||
success = __readdir_r ((DIR *) stream, &dirbuf, &d) >= 0;
|
|
||||||
#else
|
|
||||||
d = readdir ((DIR *) stream);
|
|
||||||
success = d != NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (! success)
|
|
||||||
break;
|
break;
|
||||||
if (! REAL_DIR_ENTRY (d))
|
if (! REAL_DIR_ENTRY (d))
|
||||||
continue;
|
continue;
|
||||||
|
@ -30,7 +30,7 @@ void
|
|||||||
__close_all_streams (void)
|
__close_all_streams (void)
|
||||||
{
|
{
|
||||||
/* We must be prepared for multi-threading on multiple calls. */
|
/* We must be prepared for multi-threading on multiple calls. */
|
||||||
if (! __libc_lock_trylock (lock) && already_called)
|
if (! __libc_lock_trylock (lock) && ! already_called)
|
||||||
{
|
{
|
||||||
/* Signal that we already did this. */
|
/* Signal that we already did this. */
|
||||||
already_called = 1;
|
already_called = 1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -12,18 +12,16 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <ansidecl.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "exit.h"
|
#include "exit.h"
|
||||||
|
|
||||||
/* Register a function to be called by exit. */
|
/* Register a function to be called by exit. */
|
||||||
int
|
int
|
||||||
DEFUN(on_exit, (func, arg),
|
__on_exit (void (*func) (int status, void *arg), void *arg)
|
||||||
void EXFUN((*func), (int status, PTR arg)) AND PTR arg)
|
|
||||||
{
|
{
|
||||||
struct exit_function *new = __new_exitfn ();
|
struct exit_function *new = __new_exitfn ();
|
||||||
|
|
||||||
@ -35,3 +33,4 @@ DEFUN(on_exit, (func, arg),
|
|||||||
new->func.on.arg = arg;
|
new->func.on.arg = arg;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
weak_alias (__on_exit, on_exit)
|
||||||
|
@ -367,6 +367,8 @@ extern int atexit __P ((void (*__func) (void)));
|
|||||||
#ifdef __USE_MISC
|
#ifdef __USE_MISC
|
||||||
/* Register a function to be called with the status
|
/* Register a function to be called with the status
|
||||||
given to `exit' and the given argument. */
|
given to `exit' and the given argument. */
|
||||||
|
extern int __on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
|
||||||
|
__ptr_t __arg));
|
||||||
extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
|
extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
|
||||||
__ptr_t __arg));
|
__ptr_t __arg));
|
||||||
#endif
|
#endif
|
||||||
|
@ -298,6 +298,9 @@ extern bool_t xdrrec_skiprecord __P ((XDR *__xdrs));
|
|||||||
/* true if no more input */
|
/* true if no more input */
|
||||||
extern bool_t xdrrec_eof __P ((XDR *__xdrs));
|
extern bool_t xdrrec_eof __P ((XDR *__xdrs));
|
||||||
|
|
||||||
|
/* free memory buffers for xdr */
|
||||||
|
extern void xdr_free __P ((xdrproc_t __proc, char *__objp));
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif /* !__XDR_HEADER__ */
|
#endif /* !__XDR_HEADER__ */
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <hurd/userlink.h>
|
#include <hurd/userlink.h>
|
||||||
@ -44,10 +44,10 @@ _longjmp_unwind (jmp_buf env, int val)
|
|||||||
assert (! __spin_lock_locked (&ss->critical_section_lock));
|
assert (! __spin_lock_locked (&ss->critical_section_lock));
|
||||||
__spin_lock (&ss->critical_section_lock);
|
__spin_lock (&ss->critical_section_lock);
|
||||||
|
|
||||||
/* Remove local signal preempters being unwound past. */
|
/* Remove local signal preemptors being unwound past. */
|
||||||
while (ss->preempters &&
|
while (ss->preemptors &&
|
||||||
_JMPBUF_UNWINDS (env[0].__jmpbuf, ss->preempters))
|
_JMPBUF_UNWINDS (env[0].__jmpbuf, ss->preemptors))
|
||||||
ss->preempters = ss->preempters->next;
|
ss->preemptors = ss->preemptors->next;
|
||||||
|
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -112,7 +112,7 @@ timer_thread (void)
|
|||||||
|
|
||||||
|
|
||||||
static sighandler_t
|
static sighandler_t
|
||||||
restart_itimer (struct hurd_signal_preempter *preempter,
|
restart_itimer (struct hurd_signal_preemptor *preemptor,
|
||||||
struct hurd_sigstate *ss,
|
struct hurd_sigstate *ss,
|
||||||
int *signo, struct hurd_signal_detail *detail)
|
int *signo, struct hurd_signal_detail *detail)
|
||||||
{
|
{
|
||||||
@ -170,18 +170,18 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old,
|
|||||||
{
|
{
|
||||||
/* Make sure the itimer thread is set up. */
|
/* Make sure the itimer thread is set up. */
|
||||||
|
|
||||||
/* Set up a signal preempter global for all threads to
|
/* Set up a signal preemptor global for all threads to
|
||||||
run `restart_itimer' each time a SIGALRM would arrive. */
|
run `restart_itimer' each time a SIGALRM would arrive. */
|
||||||
static struct hurd_signal_preempter preempter =
|
static struct hurd_signal_preemptor preemptor =
|
||||||
{
|
{
|
||||||
__sigmask (SIGALRM), 0, 0,
|
__sigmask (SIGALRM), 0, 0,
|
||||||
&restart_itimer,
|
&restart_itimer,
|
||||||
};
|
};
|
||||||
__mutex_lock (&_hurd_siglock);
|
__mutex_lock (&_hurd_siglock);
|
||||||
if (! preempter.next && _hurdsig_preempters != &preempter)
|
if (! preemptor.next && _hurdsig_preemptors != &preemptor)
|
||||||
{
|
{
|
||||||
preempter.next = _hurdsig_preempters;
|
preemptor.next = _hurdsig_preemptors;
|
||||||
_hurdsig_preempters = &preempter;
|
_hurdsig_preemptors = &preemptor;
|
||||||
}
|
}
|
||||||
__mutex_unlock (&_hurd_siglock);
|
__mutex_unlock (&_hurd_siglock);
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
@ -30,13 +30,13 @@ __sigwait (const sigset_t *set, int *sig)
|
|||||||
struct hurd_sigstate *ss;
|
struct hurd_sigstate *ss;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
int signo = 0;
|
int signo = 0;
|
||||||
struct hurd_signal_preempter preempter;
|
struct hurd_signal_preemptor preemptor;
|
||||||
jmp_buf buf;
|
jmp_buf buf;
|
||||||
mach_port_t wait;
|
mach_port_t wait;
|
||||||
mach_msg_header_t msg;
|
mach_msg_header_t msg;
|
||||||
|
|
||||||
sighandler_t
|
sighandler_t
|
||||||
preempt_fun (struct hurd_signal_preempter *pe,
|
preempt_fun (struct hurd_signal_preemptor *pe,
|
||||||
struct hurd_sigstate *ss,
|
struct hurd_sigstate *ss,
|
||||||
int *sigp,
|
int *sigp,
|
||||||
struct hurd_signal_detail *detail)
|
struct hurd_signal_detail *detail)
|
||||||
@ -89,16 +89,16 @@ __sigwait (const sigset_t *set, int *sig)
|
|||||||
|
|
||||||
if (!setjmp (buf))
|
if (!setjmp (buf))
|
||||||
{
|
{
|
||||||
/* Make the preempter */
|
/* Make the preemptor */
|
||||||
preempter.signals = mask;
|
preemptor.signals = mask;
|
||||||
preempter.first = 0;
|
preemptor.first = 0;
|
||||||
preempter.last = -1;
|
preemptor.last = -1;
|
||||||
preempter.preempter = preempt_fun;
|
preemptor.preemptor = preempt_fun;
|
||||||
preempter.handler = handler;
|
preemptor.handler = handler;
|
||||||
|
|
||||||
/* Install this preempter */
|
/* Install this preemptor */
|
||||||
preempter.next = ss->preempters;
|
preemptor.next = ss->preemptors;
|
||||||
ss->preempters = &preempter;
|
ss->preemptors = &preemptor;
|
||||||
|
|
||||||
__spin_unlock (&ss->lock);
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
@ -113,9 +113,9 @@ __sigwait (const sigset_t *set, int *sig)
|
|||||||
|
|
||||||
__spin_lock (&ss->lock);
|
__spin_lock (&ss->lock);
|
||||||
|
|
||||||
/* Delete our preempter. */
|
/* Delete our preemptor. */
|
||||||
assert (ss->preempters == &preempter);
|
assert (ss->preemptors == &preemptor);
|
||||||
ss->preempters = preempter.next;
|
ss->preemptors = preemptor.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ typedef struct __libc_lock_opaque__ __libc_lock_t;
|
|||||||
#define __libc_lock_lock(NAME) __mutex_lock (&(NAME))
|
#define __libc_lock_lock(NAME) __mutex_lock (&(NAME))
|
||||||
|
|
||||||
/* Lock the named lock variable. */
|
/* Lock the named lock variable. */
|
||||||
#define __libc_lock_trylock(NAME) __mutex_trylock (&(NAME))
|
#define __libc_lock_trylock(NAME) (!__mutex_trylock (&(NAME)))
|
||||||
|
|
||||||
/* Unlock the named lock variable. */
|
/* Unlock the named lock variable. */
|
||||||
#define __libc_lock_unlock(NAME) __mutex_unlock (&(NAME))
|
#define __libc_lock_unlock(NAME) __mutex_unlock (&(NAME))
|
||||||
|
@ -187,10 +187,6 @@ extern char *alloca ();
|
|||||||
#define __getcwd getcwd
|
#define __getcwd getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined HAVE_READDIR_R && !defined _LIBC
|
|
||||||
#define __readdir_r readdir_r
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get the pathname of the current working directory, and put it in SIZE
|
/* Get the pathname of the current working directory, and put it in SIZE
|
||||||
bytes of BUF. Returns NULL if the directory couldn't be determined or
|
bytes of BUF. Returns NULL if the directory couldn't be determined or
|
||||||
SIZE was too small. If successful, returns BUF. In GNU, if BUF is
|
SIZE was too small. If successful, returns BUF. In GNU, if BUF is
|
||||||
@ -254,9 +250,6 @@ __getcwd (buf, size)
|
|||||||
{
|
{
|
||||||
register DIR *dirstream;
|
register DIR *dirstream;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
#if defined HAVE_READDIR_R || defined _LIBC
|
|
||||||
struct dirent dirbuf;
|
|
||||||
#endif
|
|
||||||
dev_t dotdev;
|
dev_t dotdev;
|
||||||
ino_t dotino;
|
ino_t dotino;
|
||||||
char mount_point;
|
char mount_point;
|
||||||
@ -299,13 +292,7 @@ __getcwd (buf, size)
|
|||||||
dirstream = __opendir (dotp);
|
dirstream = __opendir (dotp);
|
||||||
if (dirstream == NULL)
|
if (dirstream == NULL)
|
||||||
goto lose;
|
goto lose;
|
||||||
while (
|
while ((d = __readdir (dirstream)) != NULL)
|
||||||
#if defined HAVE_READDIR_R || defined _LIBC
|
|
||||||
__readdir_r (dirstream, &dirbuf, &d) >= 0
|
|
||||||
#else
|
|
||||||
(d = __readdir (dirstream)) != NULL
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (d->d_name[0] == '.' &&
|
if (d->d_name[0] == '.' &&
|
||||||
(d->d_name[1] == '\0' ||
|
(d->d_name[1] == '\0' ||
|
||||||
|
@ -41,7 +41,7 @@ ttyname (fd)
|
|||||||
dev_t mydev;
|
dev_t mydev;
|
||||||
ino_t myino;
|
ino_t myino;
|
||||||
DIR *dirstream;
|
DIR *dirstream;
|
||||||
struct dirent dirbuf, *d;
|
struct dirent *d;
|
||||||
int save = errno;
|
int save = errno;
|
||||||
|
|
||||||
if (!__isatty (fd))
|
if (!__isatty (fd))
|
||||||
@ -56,7 +56,7 @@ ttyname (fd)
|
|||||||
if (dirstream == NULL)
|
if (dirstream == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (__readdir_r (dirstream, &dirbuf, &d) >= 0)
|
while ((d = readdir (dirstream)) != NULL)
|
||||||
if ((ino_t) d->d_fileno == myino)
|
if ((ino_t) d->d_fileno == myino)
|
||||||
{
|
{
|
||||||
size_t dlen = _D_ALLOC_NAMLEN (d);
|
size_t dlen = _D_ALLOC_NAMLEN (d);
|
||||||
@ -66,7 +66,11 @@ ttyname (fd)
|
|||||||
namelen = 2 * (sizeof (dev) + dlen); /* Big enough. */
|
namelen = 2 * (sizeof (dev) + dlen); /* Big enough. */
|
||||||
name = malloc (namelen);
|
name = malloc (namelen);
|
||||||
if (! name)
|
if (! name)
|
||||||
|
{
|
||||||
|
/* Perhaps it helps to free the directory stream buffer. */
|
||||||
|
(void) closedir (dirstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
(void) memcpy (name, dev, sizeof (dev) - 1);
|
(void) memcpy (name, dev, sizeof (dev) - 1);
|
||||||
name[sizeof (dev) - 1] = '/';
|
name[sizeof (dev) - 1] = '/';
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ __ttyname_r (fd, buf, buflen)
|
|||||||
dev_t mydev;
|
dev_t mydev;
|
||||||
ino_t myino;
|
ino_t myino;
|
||||||
DIR *dirstream;
|
DIR *dirstream;
|
||||||
struct dirent dirbuf, *d;
|
struct dirent *d;
|
||||||
int save = errno;
|
int save = errno;
|
||||||
|
|
||||||
/* Test for the absolute minimal size. This makes life easier inside
|
/* Test for the absolute minimal size. This makes life easier inside
|
||||||
@ -74,7 +74,7 @@ __ttyname_r (fd, buf, buflen)
|
|||||||
buf[sizeof (dev) - 1] = '/';
|
buf[sizeof (dev) - 1] = '/';
|
||||||
buflen -= sizeof (dev);
|
buflen -= sizeof (dev);
|
||||||
|
|
||||||
while (__readdir_r (dirstream, &dirbuf, &d) >= 0)
|
while ((d = readdir (dirstream)) != NULL)
|
||||||
if ((ino_t) d->d_fileno == myino)
|
if ((ino_t) d->d_fileno == myino)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
|
@ -1 +1,2 @@
|
|||||||
clone.S
|
clone.S
|
||||||
|
mremap.S
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
# Linux/m68k uses Motorola asm syntax and the ELF format.
|
# Linux/m68k uses Motorola asm syntax and the ELF format.
|
||||||
|
|
||||||
m68k-syntax-flag = -DMOTOROLA_SYNTAX
|
m68k-syntax-flag = -DMOTOROLA_SYNTAX
|
||||||
|
|
||||||
|
ifeq ($(subdir),misc)
|
||||||
|
sysdep_routines += mremap
|
||||||
|
endif
|
||||||
|
@ -14,8 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _SCHEDBITS_H
|
#ifndef _SCHEDBITS_H
|
||||||
@ -44,6 +44,8 @@ struct sched_param
|
|||||||
/* Clone current process. The parameter list of FN is not for true. Only
|
/* Clone current process. The parameter list of FN is not for true. Only
|
||||||
dots is not allowed by ISO C and without argument the compiler would
|
dots is not allowed by ISO C and without argument the compiler would
|
||||||
complain about a missing parameter list. */
|
complain about a missing parameter list. */
|
||||||
|
extern int __clone __P ((int (*__fn) (void *, ...), void *__child_stack,
|
||||||
|
int __flags, int __nargs, ...));
|
||||||
extern int clone __P ((int (*__fn) (void *, ...), void *__child_stack,
|
extern int clone __P ((int (*__fn) (void *, ...), void *__child_stack,
|
||||||
int __flags, int __nargs, ...));
|
int __flags, int __nargs, ...));
|
||||||
|
|
||||||
|
@ -48,7 +48,11 @@
|
|||||||
* Defaults on "first" open.
|
* Defaults on "first" open.
|
||||||
*/
|
*/
|
||||||
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
|
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
|
||||||
|
#ifdef OXTABS
|
||||||
#define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
|
#define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
|
||||||
|
#else
|
||||||
|
#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
|
||||||
|
#endif
|
||||||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
|
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
|
||||||
#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
|
#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
|
||||||
#define TTYDEF_SPEED (B9600)
|
#define TTYDEF_SPEED (B9600)
|
||||||
@ -58,10 +62,18 @@
|
|||||||
*/
|
*/
|
||||||
#define CTRL(x) (x&037)
|
#define CTRL(x) (x&037)
|
||||||
#define CEOF CTRL('d')
|
#define CEOF CTRL('d')
|
||||||
|
#ifdef _POSIX_VDISABLE
|
||||||
|
#define CEOL _POSIX_VDISABLE
|
||||||
|
#else
|
||||||
#define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
|
#define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
|
||||||
|
#endif
|
||||||
#define CERASE 0177
|
#define CERASE 0177
|
||||||
#define CINTR CTRL('c')
|
#define CINTR CTRL('c')
|
||||||
|
#ifdef _POSIX_VDISABLE
|
||||||
|
#define CSTATUS _POSIX_VDISABLE
|
||||||
|
#else
|
||||||
#define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
|
#define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
|
||||||
|
#endif
|
||||||
#define CKILL CTRL('u')
|
#define CKILL CTRL('u')
|
||||||
#define CMIN 1
|
#define CMIN 1
|
||||||
#define CQUIT 034 /* FS, ^\ */
|
#define CQUIT 034 /* FS, ^\ */
|
||||||
|
@ -146,7 +146,3 @@ CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
|
|||||||
CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
|
CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
|
||||||
CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
|
CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
|
||||||
CFLAGS-tzfile.c = $(tz-cflags)
|
CFLAGS-tzfile.c = $(tz-cflags)
|
||||||
|
|
||||||
ifeq ($(malloc),new-malloc)
|
|
||||||
CFLAGS-ap.c = -DNO_MCHECK
|
|
||||||
endif
|
|
||||||
|
@ -29,9 +29,7 @@ main (int argc, char **argv)
|
|||||||
char buf[20];
|
char buf[20];
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
#ifndef NO_MCHECK
|
|
||||||
mcheck (NULL);
|
mcheck (NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
fprintf(stderr, "Usage: %s\n", argv[0]);
|
fprintf(stderr, "Usage: %s\n", argv[0]);
|
||||||
|
@ -27,10 +27,7 @@
|
|||||||
char *
|
char *
|
||||||
ctime (const time_t *t)
|
ctime (const time_t *t)
|
||||||
{
|
{
|
||||||
static char buf[64]; /* POSIX.1 suggests at least 26 bytes. */
|
/* The C Standard says ctime (t) is equivalent to asctime (localtime (t)).
|
||||||
struct tm tm;
|
In particular, ctime and asctime must yield the same pointer. */
|
||||||
struct tm *tp = __localtime_r (t, &tm);
|
return asctime (localtime (t));
|
||||||
if (tp == NULL)
|
|
||||||
return NULL;
|
|
||||||
return __asctime_r (tp, buf);
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Cambridge, MA 02139, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -24,6 +24,10 @@ Cambridge, MA 02139, USA. */
|
|||||||
/* The C Standard says that localtime and gmtime return the same pointer. */
|
/* The C Standard says that localtime and gmtime return the same pointer. */
|
||||||
struct tm _tmbuf;
|
struct tm _tmbuf;
|
||||||
|
|
||||||
|
/* Prototype for the internal function to get information based on TZ. */
|
||||||
|
extern void __tzset_internal __P ((void));
|
||||||
|
|
||||||
|
|
||||||
/* Return the `struct tm' representation of *TIMER in the local timezone. */
|
/* Return the `struct tm' representation of *TIMER in the local timezone. */
|
||||||
struct tm *
|
struct tm *
|
||||||
localtime (timer)
|
localtime (timer)
|
||||||
@ -57,7 +61,7 @@ __localtime_r (timer, tp)
|
|||||||
__libc_lock_lock (__tzset_lock);
|
__libc_lock_lock (__tzset_lock);
|
||||||
|
|
||||||
/* Make sure the database is initialized. */
|
/* Make sure the database is initialized. */
|
||||||
__tzset ();
|
__tzset_internal ();
|
||||||
|
|
||||||
if (__use_tzfile)
|
if (__use_tzfile)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,8 @@ extern char *tzname[];
|
|||||||
# define gmtime_r __gmtime_r
|
# define gmtime_r __gmtime_r
|
||||||
# define localtime_r __localtime_r
|
# define localtime_r __localtime_r
|
||||||
extern int __tz_compute __P ((time_t timer, const struct tm *tm));
|
extern int __tz_compute __P ((time_t timer, const struct tm *tm));
|
||||||
|
# define tzname __tzname
|
||||||
|
# define tzset __tzset
|
||||||
#else
|
#else
|
||||||
# if ! HAVE_LOCALTIME_R
|
# if ! HAVE_LOCALTIME_R
|
||||||
# if ! HAVE_TM_GMTOFF
|
# if ! HAVE_TM_GMTOFF
|
||||||
|
14
time/tzset.c
14
time/tzset.c
@ -78,7 +78,7 @@ static char *old_tz = NULL;
|
|||||||
|
|
||||||
/* Interpret the TZ envariable. */
|
/* Interpret the TZ envariable. */
|
||||||
void
|
void
|
||||||
__tzset ()
|
__tzset_internal ()
|
||||||
{
|
{
|
||||||
register const char *tz;
|
register const char *tz;
|
||||||
register size_t l;
|
register size_t l;
|
||||||
@ -374,7 +374,7 @@ size_t __tzname_cur_max;
|
|||||||
long int
|
long int
|
||||||
__tzname_max ()
|
__tzname_max ()
|
||||||
{
|
{
|
||||||
__tzset ();
|
__tzset_internal ();
|
||||||
|
|
||||||
return __tzname_cur_max;
|
return __tzname_cur_max;
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ __tz_compute (timer, tm)
|
|||||||
time_t timer;
|
time_t timer;
|
||||||
const struct tm *tm;
|
const struct tm *tm;
|
||||||
{
|
{
|
||||||
__tzset ();
|
__tzset_internal ();
|
||||||
|
|
||||||
if (! compute_change (&tz_rules[0], 1900 + tm->tm_year) ||
|
if (! compute_change (&tz_rules[0], 1900 + tm->tm_year) ||
|
||||||
! compute_change (&tz_rules[1], 1900 + tm->tm_year))
|
! compute_change (&tz_rules[1], 1900 + tm->tm_year))
|
||||||
@ -505,14 +505,11 @@ __libc_lock_define (, __tzset_lock)
|
|||||||
#undef tzset
|
#undef tzset
|
||||||
|
|
||||||
void
|
void
|
||||||
#ifdef weak_function
|
__tzset (void)
|
||||||
weak_function
|
|
||||||
#endif
|
|
||||||
tzset (void)
|
|
||||||
{
|
{
|
||||||
__libc_lock_lock (__tzset_lock);
|
__libc_lock_lock (__tzset_lock);
|
||||||
|
|
||||||
__tzset ();
|
__tzset_internal ();
|
||||||
|
|
||||||
if (!__use_tzfile)
|
if (!__use_tzfile)
|
||||||
{
|
{
|
||||||
@ -523,3 +520,4 @@ tzset (void)
|
|||||||
|
|
||||||
__libc_lock_unlock (__tzset_lock);
|
__libc_lock_unlock (__tzset_lock);
|
||||||
}
|
}
|
||||||
|
weak_alias (__tzset, tzset)
|
||||||
|
@ -13,8 +13,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -27,7 +27,7 @@ extern unsigned int *__ctype32_b;
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
iswctype (wint_t wc, wctype_t desc)
|
__iswctype (wint_t wc, wctype_t desc)
|
||||||
{
|
{
|
||||||
size_t idx;
|
size_t idx;
|
||||||
|
|
||||||
@ -37,3 +37,4 @@ iswctype (wint_t wc, wctype_t desc)
|
|||||||
|
|
||||||
return __ctype32_b[idx] & desc;
|
return __ctype32_b[idx] & desc;
|
||||||
}
|
}
|
||||||
|
weak_alias (__iswctype, iswctype)
|
||||||
|
@ -152,6 +152,7 @@ extern wctype_t wctype __P ((__const char *__property));
|
|||||||
|
|
||||||
/* Determine whether the wide-character WC has the property described by
|
/* Determine whether the wide-character WC has the property described by
|
||||||
DESC. */
|
DESC. */
|
||||||
|
extern int __iswctype __P ((wint_t __wc, wctype_t __desc));
|
||||||
extern int iswctype __P ((wint_t __wc, wctype_t __desc));
|
extern int iswctype __P ((wint_t __wc, wctype_t __desc));
|
||||||
|
|
||||||
|
|
||||||
@ -179,20 +180,20 @@ extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc));
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __NO_WCTYPE
|
#ifndef __NO_WCTYPE
|
||||||
#define iswalnum(wc) iswctype ((wc), _ISalnum)
|
#define iswalnum(wc) __iswctype ((wc), _ISalnum)
|
||||||
#define iswalpha(wc) iswctype ((wc), _ISalpha)
|
#define iswalpha(wc) __iswctype ((wc), _ISalpha)
|
||||||
#define iswcntrl(wc) iswctype ((wc), _IScntrl)
|
#define iswcntrl(wc) __iswctype ((wc), _IScntrl)
|
||||||
#define iswdigit(wc) iswctype ((wc), _ISdigit)
|
#define iswdigit(wc) __iswctype ((wc), _ISdigit)
|
||||||
#define iswlower(wc) iswctype ((wc), _ISlower)
|
#define iswlower(wc) __iswctype ((wc), _ISlower)
|
||||||
#define iswgraph(wc) iswctype ((wc), _ISgraph)
|
#define iswgraph(wc) __iswctype ((wc), _ISgraph)
|
||||||
#define iswprint(wc) iswctype ((wc), _ISprint)
|
#define iswprint(wc) __iswctype ((wc), _ISprint)
|
||||||
#define iswpunct(wc) iswctype ((wc), _ISpunct)
|
#define iswpunct(wc) __iswctype ((wc), _ISpunct)
|
||||||
#define iswspace(wc) iswctype ((wc), _ISspace)
|
#define iswspace(wc) __iswctype ((wc), _ISspace)
|
||||||
#define iswupper(wc) iswctype ((wc), _ISupper)
|
#define iswupper(wc) __iswctype ((wc), _ISupper)
|
||||||
#define iswxdigit(wc) iswctype ((wc), _ISxdigit)
|
#define iswxdigit(wc) __iswctype ((wc), _ISxdigit)
|
||||||
|
|
||||||
#ifdef __USE_GNU
|
#ifdef __USE_GNU
|
||||||
#define iswblank(wc) iswctype ((wc), _ISblank)
|
#define iswblank(wc) __iswctype ((wc), _ISblank)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pointer to conversion tables. */
|
/* Pointer to conversion tables. */
|
||||||
|
Reference in New Issue
Block a user