1997-04-09 01:24  Ulrich Drepper  <drepper@cygnus.com>

	* rellns-sh: Rewrite to work also in presence of symlinks.

	* arpg/argp-fmtstream.c: Add casts to prevent warnings.
	* argp/argp-fmtstream.h: Likewise.
	* argp/argp-help.c: Likewise.

	* elf/dl-minimal.c: Add definition of calloc.
	* elf/version.c: Add casts to prevent warnings.
	(_dl_check_map_versions): Use calloc instead of malloc+memset.

	* locale/setlocale.c (_nl_current): Add element with index LC_ALL.
	Reported by Greg McGary <gkm@eng.ascend.com>.

	* manual/libc.texinfo: Update malloc documentation for new malloc.
	* manual/memory.texi: Likewise.
	Patch by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>.

	* math/libm-test.c (check_long): New function.
	(check_longlong): New function.
	(rinttol_test): New function.
	(rinttoll_test): New function.

	* nis/nss_compat/compat-grp.c (in_blacklist): Improve a bit.
	* nis/nss_compat/compat-pwd.c: Likewise.
	* nis/nss_compat/compat-spwd.c: Likewise.

	* stdlib/erand48_r.c (erand48_r): Build double value using
	ieee754_double union and use random bits in different order to
	increase effect of seed.
	Reported by David Mosberger-Tang <davidm@AZStarNet.com>.

	* sunrpc/svc_auth.c: Moved to ...
	* sysdeps/generic/svc_auth.c: ...here.

	* time/time.h: Pretty print.

1997-04-08 07:19  H.J. Lu  <hjl@gnu.ai.mit.edu>

	* libio/genops.c (_IO_flush_all_linebuffered): don't flush on
	a read-only stream.

1997-04-09 01:19  Ulrich Drepper  <drepper@cygnus.com>

	* malloc/malloc.c (mALLOC_STATs) [MALLOC_DEBUG>1]: Put declaration
	in correct place.
	Patch by Marcus G. Daniels <marcus@cathcart.sysc.pdx.edu>.

1997-04-07 15:34  Ulrich Drepper  <drepper@cygnus.com>

	* stdio-common/Makefile (tests): Add tst-ferror.
	* stdio-common/tst-ferror.c: New file.  Some tests for error
	indicator of streams.
	* stdio-common/tst-ferror.input: New file.

	* isomac.c: Let tests not fail because the compiler defines itself
	symbols which violate the name space rules.  gcc defines symbols
	for the architecture which are not protected by an underscore
	character.

	* math/Makefile (libm-support): Add s_rinttol and s_rinttoll.
	(libm-calls): Add s_clog.
	* sysdeps/libm-ieee754/s_clog.c: New file.  Implementation of
	logarithm of complex value.
	* sysdeps/libm-ieee754/s_clogf.c: New file.
	* sysdeps/libm-ieee754/s_clogl.c: New file.
	* math/libm-test.c (clog_test): Compile this function.  Fix a few
	typos.
	(main): Call clog_test.

	* sysdeps/libm-ieee754/s_rinttol.c: New file.  Round long double
	value to long int.
	* sysdeps/libm-i387/s_rinttol.S: New file.
	* sysdeps/libm-ieee754/s_rinttoll.c: new file.  Round long double
	value to long long int.
	* sysdeps/libm-i387/s_rinttoll.S: New file.

	* sysdeps/libm-ieee754/s_rintl.c: Many corrections.  The previous
	version was full of errors.

	* math/math.h (rinttol): Argument is of type `long double' not
	`double'.
	(rinttoll): Likewise.
	(roundtol): Likewise.
	(roundtoll): Likewise.

1997-04-06 11:32  H.J. Lu  <hjl@gnu.ai.mit.edu>

	* posix/getopt.c (_getopt_initialize): Preserve optind.
	(_getopt_internal): Set optind to 1 if optind == 0 before
	calling _getopt_initialize ().

1997-04-05 16:45  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

	* nis/rpcsvc/nislib.h: Change const nis_name to new type
	const_nis_name.
	* nis/nis_intern.c: Likewise.
	* nis/nis_intern.h: Likewise.
	* nis/nis_server.c: Likewise.
	* nis/nis_subr.c: Likewise.
	* nis/nis_table.c: Likewise.
	* nis/nis_names.c: Likewise.  Fill out ns_request structure in
	nis_add().

	* nis/nss_compat/compat-pwd.c: Use reentrant netgroup functions.
	* nis/nss_compat/compat-spwd.c: Likewise.

1997-03-27 07:37  H.J. Lu  <hjl@gnu.ai.mit.edu>

	* libio/fileops.c (_IO_file_overflow): Set error when try to write
	on a read-only stream.

	* sysdeps/gnu/utmpbits.h (ut_xtime): New symbol.
	(ut_time): Define it only if _NO_UT_TIME is not defined.

1997-04-06 00:42  Ulrich Drepper  <drepper@cygnus.com>

	* misc/tst-tsearch.c: Include <string.h>.  Define _GNU_SOURCE only
	if not already defined.

1997-04-05 16:14  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/netatalk/at.h: Include <sys/socket.h> to
	get definition of sa_family_t for <linux/atalk.h>.
	Reported by a sun <asun@zoology.washington.edu>.

	* malloc/malloc.c (cALLOc): Little optimization.
This commit is contained in:
Ulrich Drepper 1997-04-08 23:42:08 +00:00
parent 26dee9c49c
commit c131718ccc
48 changed files with 1748 additions and 389 deletions

View File

@ -17,3 +17,4 @@ distinfo
crypt
linuxthreads
localedata
secure_rpc

129
ChangeLog
View File

@ -1,3 +1,132 @@
1997-04-09 01:24 Ulrich Drepper <drepper@cygnus.com>
* rellns-sh: Rewrite to work also in presence of symlinks.
* arpg/argp-fmtstream.c: Add casts to prevent warnings.
* argp/argp-fmtstream.h: Likewise.
* argp/argp-help.c: Likewise.
* elf/dl-minimal.c: Add definition of calloc.
* elf/version.c: Add casts to prevent warnings.
(_dl_check_map_versions): Use calloc instead of malloc+memset.
* locale/setlocale.c (_nl_current): Add element with index LC_ALL.
Reported by Greg McGary <gkm@eng.ascend.com>.
* manual/libc.texinfo: Update malloc documentation for new malloc.
* manual/memory.texi: Likewise.
Patch by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>.
* math/libm-test.c (check_long): New function.
(check_longlong): New function.
(rinttol_test): New function.
(rinttoll_test): New function.
* nis/nss_compat/compat-grp.c (in_blacklist): Improve a bit.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* stdlib/erand48_r.c (erand48_r): Build double value using
ieee754_double union and use random bits in different order to
increase effect of seed.
Reported by David Mosberger-Tang <davidm@AZStarNet.com>.
* sunrpc/svc_auth.c: Moved to ...
* sysdeps/generic/svc_auth.c: ...here.
* time/time.h: Pretty print.
1997-04-08 07:19 H.J. Lu <hjl@gnu.ai.mit.edu>
* libio/genops.c (_IO_flush_all_linebuffered): don't flush on
a read-only stream.
1997-04-09 01:19 Ulrich Drepper <drepper@cygnus.com>
* malloc/malloc.c (mALLOC_STATs) [MALLOC_DEBUG>1]: Put declaration
in correct place.
Patch by Marcus G. Daniels <marcus@cathcart.sysc.pdx.edu>.
1997-04-07 15:34 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/Makefile (tests): Add tst-ferror.
* stdio-common/tst-ferror.c: New file. Some tests for error
indicator of streams.
* stdio-common/tst-ferror.input: New file.
* isomac.c: Let tests not fail because the compiler defines itself
symbols which violate the name space rules. gcc defines symbols
for the architecture which are not protected by an underscore
character.
* math/Makefile (libm-support): Add s_rinttol and s_rinttoll.
(libm-calls): Add s_clog.
* sysdeps/libm-ieee754/s_clog.c: New file. Implementation of
logarithm of complex value.
* sysdeps/libm-ieee754/s_clogf.c: New file.
* sysdeps/libm-ieee754/s_clogl.c: New file.
* math/libm-test.c (clog_test): Compile this function. Fix a few
typos.
(main): Call clog_test.
* sysdeps/libm-ieee754/s_rinttol.c: New file. Round long double
value to long int.
* sysdeps/libm-i387/s_rinttol.S: New file.
* sysdeps/libm-ieee754/s_rinttoll.c: new file. Round long double
value to long long int.
* sysdeps/libm-i387/s_rinttoll.S: New file.
* sysdeps/libm-ieee754/s_rintl.c: Many corrections. The previous
version was full of errors.
* math/math.h (rinttol): Argument is of type `long double' not
`double'.
(rinttoll): Likewise.
(roundtol): Likewise.
(roundtoll): Likewise.
1997-04-06 11:32 H.J. Lu <hjl@gnu.ai.mit.edu>
* posix/getopt.c (_getopt_initialize): Preserve optind.
(_getopt_internal): Set optind to 1 if optind == 0 before
calling _getopt_initialize ().
1997-04-05 16:45 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/rpcsvc/nislib.h: Change const nis_name to new type
const_nis_name.
* nis/nis_intern.c: Likewise.
* nis/nis_intern.h: Likewise.
* nis/nis_server.c: Likewise.
* nis/nis_subr.c: Likewise.
* nis/nis_table.c: Likewise.
* nis/nis_names.c: Likewise. Fill out ns_request structure in
nis_add().
* nis/nss_compat/compat-pwd.c: Use reentrant netgroup functions.
* nis/nss_compat/compat-spwd.c: Likewise.
1997-03-27 07:37 H.J. Lu <hjl@gnu.ai.mit.edu>
* libio/fileops.c (_IO_file_overflow): Set error when try to write
on a read-only stream.
* sysdeps/gnu/utmpbits.h (ut_xtime): New symbol.
(ut_time): Define it only if _NO_UT_TIME is not defined.
1997-04-06 00:42 Ulrich Drepper <drepper@cygnus.com>
* misc/tst-tsearch.c: Include <string.h>. Define _GNU_SOURCE only
if not already defined.
1997-04-05 16:14 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/netatalk/at.h: Include <sys/socket.h> to
get definition of sa_family_t for <linux/atalk.h>.
Reported by a sun <asun@zoology.washington.edu>.
* malloc/malloc.c (cALLOc): Little optimization.
1997-04-05 03:11 Ulrich Drepper <drepper@cygnus.com>
* inet/arpa/inet.h: Rewrite. Don't use the ugly BSD way to write

View File

@ -58,10 +58,7 @@ contact <bug-glibc@prep.ai.mit.edu>
- exp2
- nearbyint
- ceil
- round
- rinttol
- rinttoll
- roundtol
- roundtoll

View File

@ -157,7 +157,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
the end of the buffer. */
nl = fs->p;
}
else if (fs->point_col + (nl - buf) < fs->rmargin)
else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
{
/* The buffer contains a full line that fits within the maximum
line width. Reset point and scan the next line. */
@ -309,7 +309,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
int
__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
{
if (fs->end - fs->p < amount)
if ((size_t) (fs->end - fs->p) < amount)
{
ssize_t wrote;
@ -330,7 +330,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
return 0;
}
if (fs->end - fs->buf < amount)
if ((size_t) (fs->end - fs->buf) < amount)
/* Gotta grow the buffer. */
{
size_t new_size = fs->end - fs->buf + amount;
@ -354,7 +354,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
ssize_t
__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
{
size_t out;
int out;
size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
do

View File

@ -238,7 +238,7 @@ ARGP_FS_EI size_t
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
{
size_t __old;
if (__fs->p - __fs->buf > __fs->point_offs)
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->lmargin;
__fs->lmargin = __lmargin;
@ -250,7 +250,7 @@ ARGP_FS_EI size_t
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
{
size_t __old;
if (__fs->p - __fs->buf > __fs->point_offs)
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->rmargin;
__fs->rmargin = __rmargin;
@ -262,7 +262,7 @@ ARGP_FS_EI size_t
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
{
size_t __old;
if (__fs->p - __fs->buf > __fs->point_offs)
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->wmargin;
__fs->wmargin = __wmargin;
@ -273,7 +273,7 @@ __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
ARGP_FS_EI size_t
__argp_fmtstream_point (argp_fmtstream_t __fs)
{
if (__fs->p - __fs->buf > __fs->point_offs)
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
return __fs->point_col >= 0 ? __fs->point_col : 0;
}

View File

@ -1086,14 +1086,14 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
if (fstr && *fstr)
{
unsigned col = __argp_fmtstream_point (stream);
unsigned int col = __argp_fmtstream_point (stream);
__argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col);
__argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col);
if (col > uparams.opt_doc_col + 3)
if (col > (unsigned int) (uparams.opt_doc_col + 3))
__argp_fmtstream_putc (stream, '\n');
else if (col >= uparams.opt_doc_col)
else if (col >= (unsigned int) uparams.opt_doc_col)
__argp_fmtstream_puts (stream, " ");
else
indent_to (stream, uparams.opt_doc_col);

View File

@ -1,5 +1,5 @@
/* Minimal replacements for basic facilities used in the dynamic linker.
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -77,6 +77,17 @@ malloc (size_t n)
return alloc_last_block;
}
/* We use this function occasionally since the real implementation may
be optimized when it can assume the memory it returns already is
set to NUL. */
void * weak_function
calloc (size_t nmemb, size_t size)
{
size_t total = nmemb * size;
void *result = malloc (total);
return memset (result, '\0', total);
}
/* This will rarely be called. */
void weak_function
free (void *ptr)

View File

@ -199,7 +199,7 @@ _dl_check_map_versions (struct link_map *map, int verbose)
aux->vna_flags & VER_FLG_WEAK);
/* Compare the version index. */
if ((aux->vna_other & 0x7fff) > ndx_high)
if ((unsigned int) (aux->vna_other & 0x7fff) > ndx_high)
ndx_high = aux->vna_other & 0x7fff;
if (aux->vna_next == 0)
@ -230,7 +230,7 @@ _dl_check_map_versions (struct link_map *map, int verbose)
ent = (ElfW(Verdef) *) (map->l_addr + def->d_un.d_ptr);
while (1)
{
if ((ent->vd_ndx & 0x7fff) > ndx_high)
if ((unsigned int) (ent->vd_ndx & 0x7fff) > ndx_high)
ndx_high = ent->vd_ndx & 0x7fff;
if (ent->vd_next == 0)
@ -247,9 +247,7 @@ _dl_check_map_versions (struct link_map *map, int verbose)
which can be indexed by the version index in the VERSYM
section. */
map->l_versions = (struct r_found_version *)
malloc ((ndx_high + 1) * sizeof (*map->l_versions));
memset (map->l_versions, '\0',
(ndx_high + 1) * sizeof (*map->l_versions));
calloc (ndx_high + 1, sizeof (*map->l_versions));
if (map->l_versions == NULL)
{
_dl_signal_error (ENOMEM, (*map->l_name ? map->l_name : _dl_argv[0]),

138
isomac.c
View File

@ -67,6 +67,10 @@
will see messages about iso646.h, wctype.h and wchar.h not being
found. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -168,18 +172,28 @@ static char *macros[] =
#define NUMBER_OF_SUFFIXES (sizeof suffix / sizeof *suffix)
#define NUMBER_OF_MACROS (sizeof macros / sizeof *macros)
/* Format string to build command to invoke compiler. */
static const char fmt[] = "\
echo \"#include <%s>\" |\
%s -E -dM -ansi -pedantic %s -D_LIBC -I. -I `%s --print-prog-name=include` -\
> %s";
/* The compiler we use (given on the command line). */
char *CC;
/* The -I parameters for CC to find all headers. */
char *INC;
static int check_header (const char *);
static const char **get_null_defines (void);
static int check_header (const char *, const char **);
int
main (int argc, char *argv[])
{
int h;
int result = 0;
const char **ignore_list;
CC = argc > 1 ? argv[1] : "gcc";
INC = argc > 2 ? argv[2] : "";
@ -190,44 +204,107 @@ main (int argc, char *argv[])
return EXIT_FAILURE;
}
/* First get list of symbols which are defined by the compiler. */
ignore_list = get_null_defines ();
for (h = 0; h < NUMBER_OF_HEADERS; ++h)
{
char file_name[HEADER_MAX];
sprintf (file_name, "%s.h", header[h]);
result |= check_header (file_name);
result |= check_header (file_name, ignore_list);
}
#if 0
/* The test suite should return errors but for now this is not
practical. Give a warning and ask the user to correct the bugs. */
return result;
#else
if (result)
fputs ("\
##########################################################################\n\
# The test suite found some problems with your system (see the generated #\n\
# isomac.out file). These are all violations of the ISO C rules and #\n\
# should be corrected. If the problem is in the libc, report it using #\n\
# the glibcbug script to <bugs@gnu.ai.mit.edu>. If it is a problem with #\n\
# your compiler, contact the compiler manufacturer. #\n\
##########################################################################\n",
stderr);
return 0;
#endif
}
static const char **
get_null_defines (void)
{
char line[BUFSIZ], *command;
char **result = NULL;
size_t result_len = 0;
size_t result_max = 0;
FILE *input;
int first = 1;
command = malloc (sizeof fmt + sizeof "/dev/null" + 2 * strlen (CC)
+ strlen (INC) + strlen (TMPFILE));
if (command == NULL)
{
puts ("No more memory.");
exit (1);
}
sprintf (command, fmt, "/dev/null", CC, INC, CC, TMPFILE);
if (system (command))
{
puts ("system() returned nonzero");
return NULL;
}
free (command);
input = fopen (TMPFILE, "r");
if (input == NULL)
{
printf ("Could not read %s: ", TMPFILE);
perror (NULL);
return NULL;
}
while (fgets (line, sizeof line, input) != NULL)
{
int i, okay = 0;
size_t endmac;
char *start, *end;
if (strlen (line) < 9 || line[7] != ' ')
{ /* "#define A" */
printf ("Malformed input, expected '#define MACRO'\ngot '%s'\n",
line);
continue;
}
if (line[8] == '_')
/* It's a safe identifier. */
continue;
if (result_len == result_max)
{
result_max += 10;
result = realloc (result, result_max * sizeof (char **));
if (result == NULL)
{
puts ("No more memory.");
exit (1);
}
}
start = &line[8];
for (end = start + 1; !isspace (*end) && *end != '\0'; ++end)
;
result[result_len++] = strndup (start, end - start);
if (first)
{
fputs ("The following identifiers will be ignored since the compiler defines them\nby default:\n", stdout);
first = 0;
}
puts (result[result_len - 1]);
}
fclose (input);
remove (TMPFILE);
return (const char **) result;
}
static int
check_header (const char *file_name)
check_header (const char *file_name, const char **except)
{
char line[BUFSIZ], *command;
FILE *input;
int result = 0;
static const char fmt[] = "\
echo \"#include <%s>\" |\
%s -E -dM -ansi -pedantic %s -D_LIBC -I. -I `%s --print-prog-name=include` -\
> %s";
command = malloc (sizeof fmt + strlen (file_name) + 2 * strlen (CC)
+ strlen (INC) + strlen (TMPFILE));
@ -260,6 +337,7 @@ echo \"#include <%s>\" |\
{
int i, okay = 0;
size_t endmac;
const char **cpp;
if (strlen (line) < 9 || line[7] != ' ')
{ /* "#define A" */
printf ("Malformed input, expected '#define MACRO'\ngot '%s'\n",
@ -278,7 +356,7 @@ echo \"#include <%s>\" |\
continue;
for (i = 0; i < NUMBER_OF_MACROS; ++i)
{
if (!strncmp (line+8, macros[i], strlen (macros[i])))
if (!strncmp (line + 8, macros[i], strlen (macros[i])))
{
++okay;
break;
@ -305,6 +383,18 @@ echo \"#include <%s>\" |\
break;
}
}
if (okay)
continue;
if (except != NULL)
for (cpp = except; *cpp != NULL; ++cpp)
{
size_t len = strlen (*cpp);
if (!strncmp (line + 8, *cpp, len) && isspace (line[8 + len]))
{
++okay;
break;
}
}
if (!okay)
{
fputs (line, stdout);

View File

@ -317,6 +317,7 @@ DEFUN(_IO_file_overflow, (f, ch),
{
if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
{
f->_flags |= _IO_ERR_SEEN;
__set_errno (EBADF);
return EOF;
}

View File

@ -49,6 +49,9 @@ static struct locale_data * *const _nl_current[] =
[category] = &_nl_current_##category,
#include "categories.def"
#undef DEFINE_CATEGORY
/* We need this additional element to simplify the code. It must
simply be != NULL. */
[LC_ALL] = (struct locale_data **) ~0ul
};
/* Array indexed by category of pointers to _nl_C_CATEGORY slots.

View File

@ -3306,11 +3306,11 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
if(mem == 0)
return 0;
#ifdef HAVE_MEMCPY
memset(mem, 0, sz);
return memset(mem, 0, sz);
#else
while(sz > 0) ((char*)mem)[--sz] = 0; /* rather inefficient */
#endif
return mem;
#endif
}
#endif
@ -3692,8 +3692,9 @@ void mALLOC_STATs()
#endif
#if !defined(NO_THREADS) && MALLOC_DEBUG > 1
if(ar_ptr != &main_arena) {
heap_info *heap;
(void)mutex_lock(&ar_ptr->mutex);
heap_info *heap = heap_for_ptr(top(ar_ptr));
heap = heap_for_ptr(top(ar_ptr));
while(heap) { dump_heap(heap); heap = heap->prev; }
(void)mutex_unlock(&ar_ptr->mutex);
}

View File

@ -210,7 +210,6 @@ Memory Allocation
calling function returns.
* Relocating Allocator:: Waste less memory, if you can tolerate
automatic relocation of the blocks you get.
* Memory Warnings:: Getting warnings when memory is nearly full.
Unconstrained Allocation

View File

@ -38,7 +38,6 @@ will be freed automatically. @xref{Variable Size Automatic}.
calling function returns.
* Relocating Allocator:: Waste less memory, if you can tolerate
automatic relocation of the blocks you get.
* Memory Warnings:: Getting warnings when memory is nearly full.
@end menu
@node Memory Concepts
@ -140,6 +139,8 @@ any time (or never).
these functions.
* Aligned Memory Blocks:: Allocating specially aligned memory:
@code{memalign} and @code{valloc}.
* Malloc Tunable Parameters:: Use @code{mallopt} to adjust allocation
parameters.
* Heap Consistency Checking:: Automatic checking for errors.
* Hooks for Malloc:: You can use these hooks for debugging
programs that use @code{malloc}.
@ -238,10 +239,10 @@ savestring (const char *ptr, size_t len)
The block that @code{malloc} gives you is guaranteed to be aligned so
that it can hold any type of data. In the GNU system, the address is
always a multiple of eight; if the size of block is 16 or more, then the
address is always a multiple of 16. Only rarely is any higher boundary
(such as a page boundary) necessary; for those cases, use
@code{memalign} or @code{valloc} (@pxref{Aligned Memory Blocks}).
always a multiple of eight on most systems, and a multiple of 16 on
64-bit systems. Only rarely is any higher boundary (such as a page
boundary) necessary; for those cases, use @code{memalign} or
@code{valloc} (@pxref{Aligned Memory Blocks}).
Note that the memory located after the end of the block is likely to be
in use for something else; perhaps a block already allocated by another
@ -368,9 +369,11 @@ xrealloc (void *ptr, size_t size)
@end smallexample
You can also use @code{realloc} to make a block smaller. The reason you
would do this is to avoid tying up a lot of memory space when only a little
is needed. Making a block smaller sometimes necessitates copying it, so it
can fail if no other space is available.
is needed.
@comment The following is no longer true with the new malloc.
@comment But it seems wise to keep the warning for other implementations.
In several allocation implementations, making a block smaller sometimes
necessitates copying it, so it can fail if no other space is available.
If the new size you specify is the same as the old size, @code{realloc}
is guaranteed to change nothing and return the same address that you gave.
@ -404,10 +407,18 @@ calloc (size_t count, size_t eltsize)
@}
@end smallexample
But in general, it is not guaranteed that @code{calloc} calls
@code{malloc} internally. Therefore, if an application provides its own
@code{malloc}/@code{realloc}/@code{free} outside the C library, it
should always define @code{calloc}, too.
@node Efficiency and Malloc
@subsection Efficiency Considerations for @code{malloc}
@cindex efficiency and @code{malloc}
@ignore
@c No longer true, see below instead.
To make the best use of @code{malloc}, it helps to know that the GNU
version of @code{malloc} always dispenses small amounts of memory in
blocks whose sizes are powers of two. It keeps separate pools for each
@ -433,6 +444,24 @@ time using it. Also, large blocks are normally fewer in number.
Therefore, for large blocks, it makes sense to use a method which takes
more time to minimize the wasted space.
@end ignore
As apposed to other versions, the @code{malloc} in GNU libc does not
round up block sizes to powers of two, neither for large nor for small
sizes. Neighboring chunks can be coalesced on a @code{free} no matter
what their size is. This makes the implementation suitable for all
kinds of allocation patterns without generally incurring high memory
waste through fragmentation.
Very large blocks (much larger than a page) are allocated with
@code{mmap} (anonymous or via @code{/dev/zero}) by this implementation.
This has the great advantage that these chunks are returned to the
system immediately when they are freed. Therefore, it cannot happen
that a large chunk becomes ``locked'' in between smaller ones and even
after calling @code{free} wastes memory. The size threshold for
@code{mmap} to be used can be adjusted with @code{mallopt}. The use of
@code{mmap} can also be disabled completely.
@node Aligned Memory Blocks
@subsection Allocating Aligned Memory Blocks
@ -440,10 +469,10 @@ more time to minimize the wasted space.
@cindex alignment (with @code{malloc})
@pindex stdlib.h
The address of a block returned by @code{malloc} or @code{realloc} in
the GNU system is always a multiple of eight. If you need a block whose
address is a multiple of a higher power of two than that, use
@code{memalign} or @code{valloc}. These functions are declared in
@file{stdlib.h}.
the GNU system is always a multiple of eight (or sixteen on 64-bit
systems). If you need a block whose address is a multiple of a higher
power of two than that, use @code{memalign} or @code{valloc}. These
functions are declared in @file{stdlib.h}.
With the GNU library, you can use @code{free} to free the blocks that
@code{memalign} and @code{valloc} return. That does not work in BSD,
@ -454,9 +483,9 @@ however---BSD does not provide any way to free such blocks.
@deftypefun {void *} memalign (size_t @var{boundary}, size_t @var{size})
The @code{memalign} function allocates a block of @var{size} bytes whose
address is a multiple of @var{boundary}. The @var{boundary} must be a
power of two! The function @code{memalign} works by calling
@code{malloc} to allocate a somewhat larger block, and then returning an
address within the block that is on the specified boundary.
power of two! The function @code{memalign} works by allocating a
somewhat larger block, and then returning an address within the block
that is on the specified boundary.
@end deftypefun
@comment malloc.h stdlib.h
@ -475,6 +504,42 @@ valloc (size_t size)
@c !!! xref getpagesize
@end deftypefun
@node Malloc Tunable Parameters
@subsection Malloc Tunable Parameters
You can adjust some parameters for dynamic memory allocation with the
@code{mallopt} function. This function is the general SVID/XPG
interface, defined in @file{malloc.h}.
@pindex malloc.h
@deftypefun int mallopt (int @var{param}, int @var{value})
When calling @code{mallopt}, the @var{param} argument specifies the
parameter to be set, and @var{value} the new value to be set. Possible
choices for @var{param}, as defined in @file{malloc.h}, are:
@table @code
@item M_TRIM_THRESHOLD
This is the minimum size (in bytes) of the top-most, releaseable chunk
that will cause @code{sbrk} to be called with a negative argument in
order to return memory to the system.
@item M_TOP_PAD
This parameter determines the amount of extra memory to obtain from the
system when a call to @code{sbrk} is required. It also specifies the
number of bytes to retain when shrinking the heap by calling @code{sbrk}
with a negative argument. This provides the necessary hysteresis in
heap size such that excessive amounts of system calls can be avoided.
@item M_MMAP_THRESHOLD
All chunks larger than this value are allocated outside the normal
heap, using the @code{mmap} system call. This way it is guaranteed
that the memory for these chunks can be returned to the system on
@code{free}.
@item M_MMAP_MAX
The maximum number of chunks to allocate with @code{mmap}. Setting this
to zero disables all use of @code{mmap}.
@end table
@end deftypefun
@node Heap Consistency Checking
@subsection Heap Consistency Checking
@ -636,44 +701,62 @@ installing such hooks.
@cindex allocation statistics
You can get information about dynamic storage allocation by calling the
@code{mstats} function. This function and its associated data type are
declared in @file{malloc.h}; they are a GNU extension.
@code{mallinfo} function. This function and its associated data type
are declared in @file{malloc.h}; they are an extension of the standard
SVID/XPG version.
@pindex malloc.h
@comment malloc.h
@comment GNU
@deftp {Data Type} {struct mstats}
@deftp {Data Type} {struct mallinfo}
This structure type is used to return information about the dynamic
storage allocator. It contains the following members:
@table @code
@item size_t bytes_total
This is the total size of memory managed by @code{malloc}, in bytes.
@item int arena
This is the total size of memory allocated with @code{sbrk} by
@code{malloc}, in bytes.
@item size_t chunks_used
This is the number of chunks in use. (The storage allocator internally
gets chunks of memory from the operating system, and then carves them up
to satisfy individual @code{malloc} requests; see @ref{Efficiency and
Malloc}.)
@item int ordblks
This is the number of chunks not in use. (The storage allocator
internally gets chunks of memory from the operating system, and then
carves them up to satisfy individual @code{malloc} requests; see
@ref{Efficiency and Malloc}.)
@item size_t bytes_used
This is the number of bytes in use.
@item int smblks
This field is unused.
@item size_t chunks_free
This is the number of chunks which are free -- that is, that have been
allocated by the operating system to your program, but which are not
now being used.
@item int hblks
This is the total number of chunks allocated with @code{mmap}.
@item int hblkhd
This is the total size of memory allocated with @code{mmap}, in bytes.
@item int usmblks
This field is unused.
@item int fsmblks
This field is unused.
@item int uordblks
This is the total size of memory occupied by chunks handed out by
@code{malloc}.
@item int fordblks
This is the total size of memory occupied by free (not in use) chunks.
@item int keepcost
This is the size of the top-most, releaseable chunk that normally
borders the end of the heap (i.e. the ``brk'' of the process).
@item size_t bytes_free
This is the number of bytes which are free.
@end table
@end deftp
@comment malloc.h
@comment GNU
@deftypefun {struct mstats} mstats (void)
@comment SVID
@deftypefun {struct mallinfo} mallinfo (void)
This function returns information about the current dynamic memory usage
in a structure of type @code{struct mstats}.
in a structure of type @code{struct mallinfo}.
@end deftypefun
@node Summary of Malloc
@ -706,6 +789,9 @@ Allocate a block of @var{size} bytes, starting on a page boundary.
Allocate a block of @var{size} bytes, starting on an address that is a
multiple of @var{boundary}. @xref{Aligned Memory Blocks}.
@item int mallopt (int @var{param}, int @var{value})
Adjust a tunable parameter. @xref{Malloc Tunable Parameters}
@item int mcheck (void (*@var{abortfn}) (void))
Tell @code{malloc} to perform occasional consistency checks on
dynamically allocated memory, and to call @var{abortfn} when an
@ -720,7 +806,7 @@ A pointer to a function that @code{realloc} uses whenever it is called.
@item void (*__free_hook) (void *@var{ptr})
A pointer to a function that @code{free} uses whenever it is called.
@item struct mstats mstats (void)
@item struct mallinfo mallinfo (void)
Return information about the current dynamic memory usage.
@xref{Statistics of Malloc}.
@end table
@ -1744,10 +1830,13 @@ If enough memory is not available, this function returns a null pointer
and does not modify @code{*@var{handleptr}}.
@end deftypefun
@node Memory Warnings
@section Memory Usage Warnings
@cindex memory usage warnings
@cindex warnings of memory almost full
@ignore
@comment No longer available...
@comment @node Memory Warnings
@comment @section Memory Usage Warnings
@comment @cindex memory usage warnings
@comment @cindex warnings of memory almost full
@pindex malloc.c
You can ask for warnings as the program approaches running out of memory
@ -1757,7 +1846,7 @@ system. This is a GNU extension declared in @file{malloc.h}.
@comment malloc.h
@comment GNU
@deftypefun void memory_warnings (void *@var{start}, void (*@var{warn-func}) (const char *))
@comment @deftypefun void memory_warnings (void *@var{start}, void (*@var{warn-func}) (const char *))
Call this function to request warnings for nearing exhaustion of virtual
memory.
@ -1775,3 +1864,5 @@ Normally it ought to display the string for the user to read.
The warnings come when memory becomes 75% full, when it becomes 85%
full, and when it becomes 95% full. Above 95% you get another warning
each time memory usage increases.
@end ignore

View File

@ -35,7 +35,8 @@ aux := fpu_control setfpucw
extra-libs := libm
extra-libs-others = $(extra-libs)
libm-support = k_standard s_lib_version s_matherr s_signgam
libm-support = k_standard s_lib_version s_matherr s_signgam \
s_rinttol s_rinttoll
libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow \
e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt k_cos \
@ -49,7 +50,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
s_remquo s_log2 s_exp2 \
conj cimag creal cabs carg s_cexp s_csinh s_ccosh
conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog
libm-routines = $(libm-support) $(libm-calls) \
$(patsubst %_rf,%f_r,$(libm-calls:=f)) \
$(long-m-$(long-double-fcts))

View File

@ -366,6 +366,63 @@ check_bool (const char *test_name, int computed)
}
static void
check_long (const char *test_name, long int computed, long int expected)
{
long int diff = computed - expected;
int result = diff == 0;
if (result)
{
if (verbose > 2)
printf ("Pass: %s\n", test_name);
}
else
{
if (verbose)
printf ("Fail: %s\n", test_name);
if (verbose > 1)
{
printf ("Result:\n");
printf (" is: %ld\n", computed);
printf (" should be: %ld\n", expected);
}
noErrors++;
}
fpstack_test (test_name);
}
static void
check_longlong (const char *test_name, long long int computed,
long long int expected)
{
long long int diff = computed - expected;
int result = diff == 0;
if (result)
{
if (verbose > 2)
printf ("Pass: %s\n", test_name);
}
else
{
if (verbose)
printf ("Fail: %s\n", test_name);
if (verbose > 1)
{
printf ("Result:\n");
printf (" is: %lld\n", computed);
printf (" should be: %lld\n", expected);
}
noErrors++;
}
fpstack_test (test_name);
}
static void
check_isnan (const char *test_name, MATHTYPE computed)
{
@ -2485,6 +2542,7 @@ ctanh_test (void)
check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
}
#endif
static void
@ -2504,7 +2562,7 @@ clog_test (void)
check ("imag(clog(0 + i0)) = 0", __imag__ result, 0);
result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
check_isinfn ("real(clog(0 - i0)) = -Inf", __real__ result);
check ("imag(clog(0 - i0)) = -0", __imag__ result, -minus_zero);
check ("imag(clog(0 - i0)) = -0", __imag__ result, minus_zero);
result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
@ -2566,10 +2624,10 @@ clog_test (void)
check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0);
result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
check ("imag(clog(+Inf - i0)) = -0", __imag__ result, -0);
check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero);
result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
check ("imag(clog(+Inf - i1)) = -0", __imag__ result, -0);
check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero);
result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
@ -2617,6 +2675,7 @@ clog_test (void)
}
#if 0
static void
csqrt_test (void)
{
@ -2740,6 +2799,46 @@ csqrt_test (void)
#endif
static void
rinttol_test (void)
{
/* XXX this test is incomplete. We need to have a way to specifiy
the rounding method and test the critical cases. So far, only
unproblematic numbers are tested. */
check_long ("rinttol(0) = 0", 0.0, 0);
check_long ("rinttol(-0) = 0", minus_zero, 0);
check_long ("rinttol(0.2) = 0", 0.2, 0);
check_long ("rinttol(-0.2) = 0", -0.2, 0);
check_long ("rinttol(1.4) = 1", 1.4, 1);
check_long ("rinttol(-1.4) = -1", -1.4, -1);
check_long ("rinttol(8388600.3) = 8388600", 8388600.3, 8388600);
check_long ("rinttol(-8388600.3) = -8388600", -8388600.3, -8388600);
}
static void
rinttoll_test (void)
{
/* XXX this test is incomplete. We need to have a way to specifiy
the rounding method and test the critical cases. So far, only
unproblematic numbers are tested. */
check_longlong ("rinttoll(0) = 0", 0.0, 0);
check_longlong ("rinttoll(-0) = 0", minus_zero, 0);
check_longlong ("rinttoll(0.2) = 0", 0.2, 0);
check_longlong ("rinttoll(-0.2) = 0", -0.2, 0);
check_longlong ("rinttoll(1.4) = 1", 1.4, 1);
check_longlong ("rinttoll(-1.4) = -1", -1.4, -1);
check_longlong ("rinttoll(8388600.3) = 8388600", 8388600.3, 8388600);
check_longlong ("rinttoll(-8388600.3) = -8388600", -8388600.3, -8388600);
}
static void
inverse_func_pair_test (const char *test_name,
mathfunc f1, mathfunc inverse,
@ -3070,6 +3169,10 @@ main (int argc, char *argv[])
cexp_test ();
csinh_test ();
ccosh_test ();
clog_test ();
rinttol_test ();
rinttoll_test ();
identities ();
inverse_functions ();

View File

@ -163,13 +163,13 @@ enum
/* Round X to nearest integral value according to current rounding
direction. */
extern long int rinttol __P ((double __x));
extern long long int rinttoll __P ((double __x));
extern long int rinttol __P ((long double __x));
extern long long int rinttoll __P ((long double __x));
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
extern long int roundtol __P ((double __x));
extern long long int roundtoll __P ((double __x));
extern long int roundtol __P ((long double __x));
extern long long int roundtoll __P ((long double __x));
/* Comparison macros. */

View File

@ -17,10 +17,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define _GNU_SOURCE 1
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
#define SEED 0

View File

@ -25,7 +25,7 @@
/* Nearly the same as nis_getnames, but nis_getnames stopped
when 2 points left */
nis_name *
__nis_expandname (const nis_name name)
__nis_expandname (const char *name)
{
nis_name *getnames = NULL;
char local_domain[NIS_MAXNAMELEN + 1];
@ -145,13 +145,13 @@ __nis_expandname (const nis_name name)
}
fd_result *
__nis_finddirectoy (nis_name dir_name)
__nis_finddirectoy (const_nis_name name)
{
fd_args args;
nis_error status;
fd_result *res;
args.dir_name = dir_name;
args.dir_name = (char *) name;
args.requester = nis_local_principal ();
res = calloc (1, sizeof (fd_result));
@ -160,7 +160,7 @@ __nis_finddirectoy (nis_name dir_name)
if ((status = __do_niscall (NULL, 0, NIS_FINDDIRECTORY,
(xdrproc_t) xdr_fd_args,
(caddr_t) & args,
(caddr_t) &args,
(xdrproc_t) xdr_fd_result,
(caddr_t) res, 0)) != RPC_SUCCESS)
res->status = status;

View File

@ -31,7 +31,7 @@ extern nis_error __do_niscall (__const nis_server *server, int server_len,
extern AUTH *authdes_pk_create (const char *, const netobj *, u_int,
struct sockaddr *, des_block *);
#endif
extern nis_name *__nis_expandname (__const nis_name);
extern nis_name *__nis_expandname (const char *);
__END_DECLS

View File

@ -25,7 +25,7 @@
#include "nis_intern.h"
nis_result *
nis_lookup (const nis_name name, const u_long flags)
nis_lookup (const_nis_name name, const u_long flags)
{
nis_result *res;
struct ns_request req;
@ -106,7 +106,7 @@ nis_lookup (const nis_name name, const u_long flags)
}
else
{
req.ns_name = name;
req.ns_name = (char *)name;
while (is_link)
{
@ -116,7 +116,7 @@ nis_lookup (const nis_name name, const u_long flags)
if ((status = __do_niscall (NULL, 0, NIS_LOOKUP,
(xdrproc_t) xdr_ns_request,
(caddr_t) & req,
(caddr_t) &req,
(xdrproc_t) xdr_nis_result,
(caddr_t) res, flags)) != RPC_SUCCESS)
{
@ -158,31 +158,55 @@ nis_lookup (const nis_name name, const u_long flags)
}
nis_result *
nis_add (const nis_name name, const nis_object *obj)
nis_add (const_nis_name name, const nis_object *obj)
{
nis_result *res;
nis_error status;
struct ns_request req;
char *p1, *p2, *p3, *p4;
char buf1 [strlen (name) + 20];
char buf4 [strlen (name) + 20];
res = calloc (1, sizeof (nis_result));
req.ns_name = name;
req.ns_name = (char *)name;
req.ns_object.ns_object_len = 1;
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
p1 = req.ns_object.ns_object_val[0].zo_name;
req.ns_object.ns_object_val[0].zo_name =
nis_name_of_r (name, buf1, sizeof (buf1));
p2 = req.ns_object.ns_object_val[0].zo_owner;
if (p2 == NULL || strlen (p2) == 0)
req.ns_object.ns_object_val[0].zo_owner = nis_local_principal ();
p3 = req.ns_object.ns_object_val[0].zo_group;
if (p3 == NULL || strlen (p3) == 0)
req.ns_object.ns_object_val[0].zo_group = nis_local_group ();
p4 = req.ns_object.ns_object_val[0].zo_domain;
req.ns_object.ns_object_val[0].zo_domain =
nis_domain_of_r (name, buf4, sizeof (buf4));
if ((status = __do_niscall (NULL, 0, NIS_ADD, (xdrproc_t) xdr_ns_request,
(caddr_t) & req, (xdrproc_t) xdr_nis_result,
(caddr_t) &req, (xdrproc_t) xdr_nis_result,
(caddr_t) res, 0)) != RPC_SUCCESS)
res->status = status;
req.ns_object.ns_object_val[0].zo_name = p1;
req.ns_object.ns_object_val[0].zo_owner = p2;
req.ns_object.ns_object_val[0].zo_group = p3;
req.ns_object.ns_object_val[0].zo_domain = p4;
nis_destroy_object (req.ns_object.ns_object_val);
return res;
}
nis_result *
nis_remove (const nis_name name, const nis_object *obj)
nis_remove (const_nis_name name, const nis_object *obj)
{
nis_result *res;
nis_error status;
@ -190,7 +214,7 @@ nis_remove (const nis_name name, const nis_object *obj)
res = calloc (1, sizeof (nis_result));
req.ns_name = name;
req.ns_name = (char *)name;
if (obj != NULL)
{
@ -214,7 +238,7 @@ nis_remove (const nis_name name, const nis_object *obj)
}
nis_result *
nis_modify (const nis_name name, const nis_object *obj)
nis_modify (const_nis_name name, const nis_object *obj)
{
nis_result *res;
nis_error status;
@ -222,7 +246,7 @@ nis_modify (const nis_name name, const nis_object *obj)
res = calloc (1, sizeof (nis_result));
req.ns_name = name;
req.ns_name = (char *)name;
req.ns_object.ns_object_len = 1;
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);

View File

@ -22,7 +22,7 @@
#include "nis_intern.h"
nis_error
nis_mkdir (const nis_name dir, const nis_server *server)
nis_mkdir (const_nis_name dir, const nis_server *server)
{
nis_error res;
@ -54,7 +54,7 @@ nis_mkdir (const nis_name dir, const nis_server *server)
}
nis_error
nis_rmdir (const nis_name dir, const nis_server *server)
nis_rmdir (const_nis_name dir, const nis_server *server)
{
nis_error res;
@ -116,7 +116,7 @@ nis_freetags (nis_tag *tags, const int numtags)
}
nis_server **
nis_getservlist (const nis_name dir)
nis_getservlist (const_nis_name dir)
{
nis_server **serv;

View File

@ -23,7 +23,7 @@
#include <rpcsvc/nislib.h>
nis_name
nis_leaf_of (const nis_name name)
nis_leaf_of (const_nis_name name)
{
static char result[NIS_MAXNAMELEN + 1];
@ -31,7 +31,7 @@ nis_leaf_of (const nis_name name)
}
nis_name
nis_leaf_of_r (const nis_name name, char *buffer, size_t buflen)
nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen)
{
size_t i = 0;
@ -53,7 +53,7 @@ nis_leaf_of_r (const nis_name name, char *buffer, size_t buflen)
}
nis_name
nis_name_of (const nis_name name)
nis_name_of (const_nis_name name)
{
static char result[NIS_MAXNAMELEN + 1];
@ -61,7 +61,7 @@ nis_name_of (const nis_name name)
}
nis_name
nis_name_of_r (const nis_name name, char *buffer, size_t buflen)
nis_name_of_r (const_nis_name name, char *buffer, size_t buflen)
{
char *local_domain;
int diff;
@ -90,7 +90,7 @@ nis_name_of_r (const nis_name name, char *buffer, size_t buflen)
}
nis_name
nis_domain_of (const nis_name name)
nis_domain_of (const_nis_name name)
{
static char result[NIS_MAXNAMELEN + 1];
@ -98,7 +98,7 @@ nis_domain_of (const nis_name name)
}
nis_name
nis_domain_of_r (const nis_name name, char *buffer, size_t buflen)
nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen)
{
char *cptr;
size_t cptr_len;
@ -122,7 +122,7 @@ nis_domain_of_r (const nis_name name, char *buffer, size_t buflen)
}
static int
count_dots (const nis_name str)
count_dots (const_nis_name str)
{
int count = 0;
size_t i;
@ -135,7 +135,7 @@ count_dots (const nis_name str)
}
nis_name *
nis_getnames (const nis_name name)
nis_getnames (const_nis_name name)
{
nis_name *getnames = NULL;
char local_domain[NIS_MAXNAMELEN + 1];
@ -267,7 +267,7 @@ nis_freenames (nis_name *names)
}
name_pos
nis_dir_cmp (const nis_name n1, const nis_name n2)
nis_dir_cmp (const_nis_name n1, const_nis_name n2)
{
int len1, len2;

View File

@ -23,7 +23,7 @@
#include "nis_intern.h"
static void
splitname (const nis_name name, nis_name *ibr_name, int *srch_len,
splitname (const_nis_name name, nis_name *ibr_name, int *srch_len,
nis_attr **srch_val)
{
char *cptr, *key, *val, *next;
@ -138,7 +138,7 @@ splitname (const nis_name name, nis_name *ibr_name, int *srch_len,
}
static struct ib_request *
__create_ib_request (const nis_name name, struct ib_request *ibreq,
__create_ib_request (const_nis_name name, struct ib_request *ibreq,
u_long flags)
{
splitname (name, &ibreq->ibr_name, &ibreq->ibr_srch.ibr_srch_len,
@ -173,8 +173,8 @@ __create_ib_request (const nis_name name, struct ib_request *ibreq,
}
nis_result *
nis_list (const nis_name name, const u_long flags,
int (*callback) (const nis_name name,
nis_list (const_nis_name name, u_long flags,
int (*callback) (const_nis_name name,
const nis_object *object,
const void *userdata),
const void *userdata)
@ -257,8 +257,8 @@ nis_list (const nis_name name, const u_long flags,
}
nis_result *
nis_add_entry (const nis_name name, const nis_object *obj,
const u_long flags)
nis_add_entry (const_nis_name name, const nis_object *obj,
u_long flags)
{
nis_result *res;
struct ib_request ibreq;
@ -289,8 +289,8 @@ nis_add_entry (const nis_name name, const nis_object *obj,
}
nis_result *
nis_modify_entry (const nis_name name, const nis_object *obj,
const u_long flags)
nis_modify_entry (const_nis_name name, const nis_object *obj,
u_long flags)
{
nis_result *res;
struct ib_request ibreq;
@ -320,8 +320,8 @@ nis_modify_entry (const nis_name name, const nis_object *obj,
}
nis_result *
nis_remove_entry (const nis_name name, const nis_object *obj,
const u_long flags)
nis_remove_entry (const_nis_name name, const nis_object *obj,
u_long flags)
{
nis_result *res;
struct ib_request ibreq;
@ -354,7 +354,7 @@ nis_remove_entry (const nis_name name, const nis_object *obj,
}
nis_result *
nis_first_entry (const nis_name name)
nis_first_entry (const_nis_name name)
{
nis_result *res;
struct ib_request ibreq;
@ -379,7 +379,7 @@ nis_first_entry (const nis_name name)
}
nis_result *
nis_next_entry (const nis_name name, const netobj *cookie)
nis_next_entry (const_nis_name name, const netobj *cookie)
{
nis_result *res;
struct ib_request ibreq;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -605,10 +605,14 @@ static bool_t
in_blacklist (const char *name, int namelen, ent_t *ent)
{
char buf[namelen + 3];
char *cp;
if (ent->blacklist.data == NULL)
return FALSE;
stpcpy (stpcpy (stpcpy (buf, "|"), name), "|");
buf[0] = '|';
cp = stpcpy (&buf[1], name);
*cp++= '|';
*cp = '\0';
return strstr (ent->blacklist.data, buf) != NULL;
}

View File

@ -735,15 +735,19 @@ getpwent_next_file (struct passwd *result, ent_t *ent,
if (result->pw_name[0] == '-' && result->pw_name[1] == '@'
&& result->pw_name[2] != '\0')
{
char buf2[1024];
char *user, *host, *domain;
struct __netgrent netgrdata;
setnetgrent (&result->pw_name[2]);
while (getnetgrent (&host, &user, &domain))
bzero (&netgrdata, sizeof (struct __netgrent));
__internal_setnetgrent (&result->pw_name[2], &netgrdata);
while (__internal_getnetgrent_r (&host, &user, &domain,
&netgrdata, buf2, sizeof (buf2)))
{
if (user != NULL && user[0] != '-')
blacklist_store_name (user, ent);
}
endnetgrent ();
__internal_endnetgrent (&netgrdata);
continue;
}
@ -979,10 +983,14 @@ static bool_t
in_blacklist (const char *name, int namelen, ent_t *ent)
{
char buf[namelen + 3];
char *cp;
if (ent->blacklist.data == NULL)
return FALSE;
stpcpy (stpcpy (stpcpy (buf, "|"), name), "|");
buf[0] = '|';
cp = stpcpy (&buf[1], name);
*cp++= '|';
*cp = '\0';
return strstr (ent->blacklist.data, buf) != NULL;
}

View File

@ -414,9 +414,9 @@ getspent_next_netgr (struct spwd *result, ent_t *ent, char *group,
char *buffer, size_t buflen)
{
if (use_nisplus)
return getpwent_next_nisplus_netgr (result, ent, group, buffer, buflen);
return getspent_next_nisplus_netgr (result, ent, group, buffer, buflen);
else
return getpwent_next_nis_netgr (result, ent, group, buffer, buflen);
return getspent_next_nis_netgr (result, ent, group, buffer, buflen);
}
static enum nss_status
@ -660,8 +660,7 @@ getspent_next_file (struct spwd *result, ent_t *ent,
struct parser_data *data = (void *) buffer;
while (1)
{
char *p, *p2;
size_t p2len;
char *p;
do
{
@ -676,10 +675,10 @@ getspent_next_file (struct spwd *result, ent_t *ent,
while (isspace (*p))
++p;
}
while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */
while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
/* Parse the line. If it is invalid, loop to
get the next line of the file to parse. */
!_nss_files_parse_spent (p, result, data, buflen));
|| !_nss_files_parse_spent (p, result, data, buflen));
if (result->sp_namp[0] != '+' && result->sp_namp[0] != '-')
/* This is a real entry. */
@ -689,15 +688,19 @@ getspent_next_file (struct spwd *result, ent_t *ent,
if (result->sp_namp[0] == '-' && result->sp_namp[1] == '@'
&& result->sp_namp[2] != '\0')
{
char buf2[1024];
char *user, *host, *domain;
struct __netgrent netgrdata;
setnetgrent (&result->sp_namp[2]);
while (getnetgrent (&host, &user, &domain))
bzero (&netgrdata, sizeof (struct __netgrent));
__internal_setnetgrent (&result->sp_namp[2], &netgrdata);
while (__internal_getnetgrent_r (&host, &user, &domain,
&netgrdata, buf2, sizeof (buf2)))
{
if (user != NULL && user[0] != '-')
blacklist_store_name (user, ent);
}
endnetgrent ();
__internal_endnetgrent (&netgrdata);
continue;
}
@ -890,16 +893,19 @@ blacklist_store_name (const char *name, ent_t *ent)
return;
}
/* returns TRUE if ent->blacklist contains name, else FALSE */
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
static bool_t
in_blacklist (const char *name, int namelen, ent_t *ent)
{
char buf[namelen + 3];
char *cp;
if (ent->blacklist.data == NULL)
return FALSE;
stpcpy (stpcpy (stpcpy (buf, "|"), name), "|");
buf[0] = '|';
cp = stpcpy (&buf[1], name);
*cp++= '|';
*cp = '\0';
return strstr (ent->blacklist.data, buf) != NULL;
}

View File

@ -24,57 +24,144 @@
__BEGIN_DECLS
/*
** nis_names
*/
extern nis_result *nis_lookup __P ((__const nis_name, const u_long));
extern nis_result *nis_add __P ((__const nis_name, const nis_object *));
extern nis_result *nis_remove __P ((__const nis_name, const nis_object *));
extern nis_result *nis_modify __P ((__const nis_name, const nis_object *));
/*
** nis_table
*/
extern nis_result *nis_list __P ((__const nis_name, const u_long,
int (*)(__const nis_name,
__const nis_object *,
__const void *), __const void *));
extern nis_result *nis_add_entry __P ((__const nis_name, __const nis_object *,
__const u_long));
extern nis_result *nis_modify_entry __P ((__const nis_name,
__const nis_object *,
__const u_long));
extern nis_result *nis_remove_entry __P ((__const nis_name,
__const nis_object *,
__const u_long));
extern nis_result *nis_first_entry __P ((__const nis_name));
extern nis_result *nis_next_entry __P ((__const nis_name, __const netobj *));
typedef const char *const_nis_name;
/* nis_names: These functions are used to locate and manipulate all NIS+
* objects except the NIS+ entry objects.
*
* nis_lookup (name, flags) resolves a NIS+ name and returns a copy of
* that object from a NIS+ server.
* const nis_name name: name of the object to be resolved
* u_long flags: logically ORing zero or more flags (FOLLOW_LINKS,
* HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME)
*
* nis_add (name, obj) adds objects to the NIS+ namespace.
* const nis_name name: fully qualified NIS+ name.
* const nis_object *obj: object members zo_name and zo_domain will be
* constructed from name.
*
* nis_remove (name, obj) removes objects from the NIS+ namespace.
* const nis_name name: fully qualified NIS+ name.
* const nis_object *obj: if not NULL, it is assumed to point to a copy
* of the object being removed. In this case, if
* the object on the server does not have the same
* object identifier as the object being passed,
* the operation will fail with the NIS_NOTSAMEOBJ
* error.
*
* nis_modify (name, obj) can change specific attributes of an object
* that already exists in the namespace.
*/
extern nis_result *nis_lookup __P ((const_nis_name name, u_long flags));
extern nis_result *nis_add __P ((const_nis_name name, const nis_object *obj));
extern nis_result *nis_remove __P ((const_nis_name name,
const nis_object *obj));
extern nis_result *nis_modify __P ((const_nis_name name,
const nis_object *obj));
/* nis_tables: These functions are used to search and modify NIS+ tables.
*
* nis_list (table_name, flags, callback(table_name, obj, userdata), userdata)
* search a table in the NIS+ namespace.
* const nis_name table_name: indexed name ([xx=yy],table.dir)
* u_long flags: logically ORing one or more flags (FOLLOW_LINKS,
* [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE],
* MASTER_ONLY, EXPAND_NAME, RETURN_RESULT)
* callback(): callback is an optional pointer to a function that will
* process the ENTRY type objects that are returned from the
* search. If this pointer is NULL, then all entries that match
* the search criteria are returned in the nis_result structure,
* otherwise this function will be called once for each
* entry returned.
* void *userdata: passed to callback function along with the returned
* entry object.
*
* nis_add_entry (table_name, obj, flags) will add the NIS+ object to the
* NIS+ table_name.
* const nis_name table_name
* const nis_object *obj
* u_long flags: 0, ADD_OVERWRITE, RETURN_RESULT
*
* nis_modify_entry (name, obj, flags) modifies an object identified by name.
* const nis_name name: object identifier
* const nis_object *obj: should point to an entry with the EN_MODIFIED
* flag set in each column that contains new
* information.
* u_long flags: 0, MOD_SAMEOBJ, RETURN_RESULT
*
* nis_remove_entry (table_name, obj, flags) removes a set of entries
* identified by table_name from the table.
* const nis_name table_name: indexed NIS+ name
* const nis_object *obj: if obj is non-null, it is presumed to point to
* a cached copy of the entry. When the removal is
* attempted, and the object that would be removed
* is not the same as the cached object pointed to
* by object then the operation will fail with an
* NIS_NOTSAMEOBJ error
* u_long flags: 0, REM_MULTIPLE
*
* nis_first_entry (table_name) fetches entries from a table one at a time.
* const nis_name table_name
*
* nis_next_entry (table_name, cookie) retrieves the "next" entry from a
* table specified by table_name.
* const nis_name table_name:
* const netobj *cookie: The value of cookie from the nis_result structure
* form the previous call.
*/
extern nis_result *nis_list __P ((const_nis_name name, u_long flags,
int (*callback)(const_nis_name table_name,
const nis_object *obj,
const void *userdata),
const void *userdata));
extern nis_result *nis_add_entry __P ((const_nis_name table_name,
const nis_object *obj, u_long flags));
extern nis_result *nis_modify_entry __P ((const_nis_name name,
const nis_object *obj,
u_long flags));
extern nis_result *nis_remove_entry __P ((const_nis_name table_name,
const nis_object *obj,
u_long flags));
extern nis_result *nis_first_entry __P ((const_nis_name table_name));
extern nis_result *nis_next_entry __P ((const_nis_name table_name,
const netobj *cookie));
/*
** nis_server
*/
extern nis_error nis_mkdir __P ((__const nis_name, __const nis_server *));
extern nis_error nis_rmdir __P ((__const nis_name, __const nis_server *));
extern nis_error nis_servstate __P ((__const nis_server *, __const nis_tag *,
__const int, nis_tag **));
extern nis_error nis_stats __P ((__const nis_server *, __const nis_tag *,
__const int, nis_tag **));
extern void nis_freetags __P ((nis_tag *, __const int));
extern nis_server **nis_getservlist __P ((__const nis_name));
extern void nis_freeservlist __P ((nis_server **));
extern nis_error nis_mkdir __P ((const_nis_name dirname,
const nis_server *machine));
extern nis_error nis_rmdir __P ((const_nis_name dirname,
const nis_server *machine));
extern nis_error nis_servstate __P ((const nis_server *machine,
const nis_tag *tags, int numtags,
nis_tag **result));
extern nis_error nis_stats __P ((const nis_server *machine,
const nis_tag *tags, int numtags,
nis_tag **result));
extern void nis_freetags __P ((nis_tag *tags, int numtags));
extern nis_server **nis_getservlist __P ((const_nis_name dirname));
extern void nis_freeservlist __P ((nis_server **machines));
/*
** nis_subr
*/
extern nis_name nis_leaf_of __P ((__const nis_name));
extern nis_name nis_leaf_of_r __P ((__const nis_name, char *, size_t));
extern nis_name nis_name_of __P ((__const nis_name));
extern nis_name nis_name_of_r __P ((__const nis_name, char *, size_t));
extern nis_name nis_domain_of __P ((__const nis_name));
extern nis_name nis_domain_of_r __P ((__const nis_name, char *, size_t));
extern nis_name *nis_getnames __P ((__const nis_name));
extern void nis_freenames __P ((nis_name *));
extern name_pos nis_dir_cmp __P ((nis_name, nis_name));
extern nis_object *nis_clone_object __P ((__const nis_object *, nis_object *));
extern void nis_destroy_object __P ((nis_object *));
extern void nis_print_object __P ((__const nis_object *));
extern nis_name nis_leaf_of __P ((const_nis_name name));
extern nis_name nis_leaf_of_r __P ((const_nis_name name, char *buffer,
size_t buflen));
extern nis_name nis_name_of __P ((const_nis_name name));
extern nis_name nis_name_of_r __P ((const_nis_name name, char *buffer,
size_t buflen));
extern nis_name nis_domain_of __P ((const_nis_name name));
extern nis_name nis_domain_of_r __P ((const_nis_name name, char *buffer,
size_t buflen));
extern nis_name *nis_getnames __P ((const_nis_name name));
extern void nis_freenames __P ((nis_name *namelist));
extern name_pos nis_dir_cmp __P ((const_nis_name n1, const_nis_name n2));
extern nis_object *nis_clone_object __P ((const nis_object *src,
nis_object *dest));
extern void nis_destroy_object __P ((nis_object *obj));
extern void nis_print_object __P ((const nis_object *obj));
/*
** nis_local_names
*/
@ -82,81 +169,92 @@ extern nis_name nis_local_group __P ((void));
extern nis_name nis_local_directory __P ((void));
extern nis_name nis_local_principal __P ((void));
extern nis_name nis_local_host __P ((void));
/*
** nis_error
*/
extern const char *nis_sperrno __P ((__const nis_error));
extern void nis_perror __P ((__const nis_error, __const char *));
extern void nis_lerror __P ((__const nis_error, __const char *));
extern char *nis_sperror __P ((__const nis_error, __const char *));
extern char *nis_sperror_r __P ((__const nis_error, __const char *,
char *, size_t));
extern const char *nis_sperrno __P ((const nis_error status));
extern void nis_perror __P ((const nis_error status, const char *label));
extern void nis_lerror __P ((const nis_error status, const char *label));
extern char *nis_sperror __P ((const nis_error status, const char *label));
extern char *nis_sperror_r __P ((const nis_error status, const char *label,
char *buffer, size_t buflen));
/*
** nis_groups
*/
extern bool_t nis_ismember __P ((__const nis_name, __const nis_name));
extern nis_error nis_addmember __P ((__const nis_name, __const nis_name));
extern nis_error nis_removemember __P ((__const nis_name, __const nis_name));
extern nis_error nis_creategroup __P ((__const nis_name, __const u_long));
extern nis_error nis_destroygroup __P ((__const nis_name));
extern void nis_print_group_entry __P ((__const nis_name));
extern nis_error nis_verifygroup __P ((__const nis_name));
extern bool_t nis_ismember __P ((const_nis_name principal,
const_nis_name group));
extern nis_error nis_addmember __P ((const_nis_name member,
const_nis_name group));
extern nis_error nis_removemember __P ((const_nis_name member,
const_nis_name group));
extern nis_error nis_creategroup __P ((const_nis_name group, u_long flags));
extern nis_error nis_destroygroup __P ((const_nis_name group));
extern void nis_print_group_entry __P ((const_nis_name group));
extern nis_error nis_verifygroup __P ((const_nis_name group));
/*
** nis_ping
*/
extern void nis_ping __P ((__const nis_name, __const u_long,
__const nis_object *));
extern nis_result *nis_checkpoint __P ((__const nis_name));
extern void nis_ping __P ((const_nis_name dirname, u_long utime,
const nis_object *dirobj));
extern nis_result *nis_checkpoint __P ((const_nis_name dirname));
/*
** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
*/
extern void nis_print_result __P ((__const nis_result *));
extern void nis_print_rights __P ((__const u_long));
extern void nis_print_directory __P ((__const directory_obj *));
extern void nis_print_group __P ((__const group_obj *));
extern void nis_print_table __P ((__const table_obj *));
extern void nis_print_link __P ((__const link_obj *));
extern void nis_print_entry __P ((__const entry_obj *));
extern void nis_print_result __P ((const nis_result *result));
extern void nis_print_rights __P ((u_long rights));
extern void nis_print_directory __P ((const directory_obj *dirobj));
extern void nis_print_group __P ((const group_obj *grpobj));
extern void nis_print_table __P ((const table_obj *tblobj));
extern void nis_print_link __P ((const link_obj *lnkobj));
extern void nis_print_entry __P ((const entry_obj *enobj));
/*
** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
*/
extern directory_obj *readColdStartFile __P ((void));
extern bool_t writeColdStartFile __P ((__const directory_obj *));
extern nis_object *nis_read_obj __P ((__const char *));
extern bool_t nis_write_obj __P ((__const char *, __const nis_object *));
extern bool_t writeColdStartFile __P ((const directory_obj *dirobj));
extern nis_object *nis_read_obj __P ((const char *obj));
extern bool_t nis_write_obj __P ((const char *file, const nis_object *obj));
/*
** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
*/
extern directory_obj *nis_clone_directory __P ((const directory_obj *src,
directory_obj *dest));
extern group_obj *nis_clone_group __P ((const group_obj *src,
group_obj *dest));
extern table_obj *nis_clone_table __P ((const table_obj *src,
table_obj *dest));
extern entry_obj *nis_clone_entry __P ((const entry_obj *src,
entry_obj *dest));
extern link_obj *nis_clone_link __P ((const link_obj *src, link_obj *dest));
extern objdata *nis_clone_objdata __P ((const objdata *src, objdata *dest));
extern nis_result *nis_clone_result __P ((const nis_result *src,
nis_result *dest));
extern directory_obj *nis_clone_directory __P ((__const directory_obj *,
directory_obj *));
extern group_obj *nis_clone_group __P ((__const group_obj *, group_obj *));
extern table_obj *nis_clone_table __P ((__const table_obj *, table_obj *));
extern entry_obj *nis_clone_entry __P ((__const entry_obj *, entry_obj *));
extern link_obj *nis_clone_link __P ((__const link_obj *, link_obj *));
extern objdata *nis_clone_objdata __P ((__const objdata *, objdata *));
extern nis_result *nis_clone_result __P ((__const nis_result *, nis_result *));
/*
** nis_free - nis_freeresult
*/
extern void nis_freeresult __P ((nis_result *));
/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
extern void nis_free_attr __P ((nis_attr *));
extern void nis_free_request __P ((ib_request *));
extern void nis_free_endpoints __P ((endpoint *, unsigned int));
extern void nis_free_servers __P ((nis_server *, unsigned int));
extern void nis_free_directory __P ((directory_obj *));
extern void nis_free_group __P ((group_obj *));
extern void nis_free_table __P ((table_obj *));
extern void nis_free_entry __P ((entry_obj *));
extern void nis_free_link __P ((link_obj *));
extern void nis_free_object __P ((nis_object *));
extern void nis_freeresult __P ((nis_result *result));
/* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
extern void nis_free_attr __P ((nis_attr *attr));
extern void nis_free_request __P ((ib_request *req));
extern void nis_free_endpoints __P ((endpoint *ep, unsigned int count));
extern void nis_free_servers __P ((nis_server *machine, unsigned int count));
extern void nis_free_directory __P ((directory_obj *dirobj));
extern void nis_free_group __P ((group_obj *grpobj));
extern void nis_free_table __P ((table_obj *tblobj));
extern void nis_free_entry __P ((entry_obj *enobj));
extern void nis_free_link __P ((link_obj *lnkobj));
extern void nis_free_object __P ((nis_object *obj));
/* This is the SUN definition, but I don't know for what we need
the directory_obj parameter */
/* extern fd_result *nis_finddirectory __P ((directory_obj *, nis_name)); */
extern fd_result *__nis_finddirectory __P ((nis_name));
extern fd_result *__nis_finddirectory __P ((const_nis_name name));
extern int __start_clock(int);
extern u_long __stop_clock(int);

View File

@ -397,7 +397,7 @@ _getopt_initialize (argc, argv, optstring)
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
first_nonopt = last_nonopt = optind = 1;
first_nonopt = last_nonopt = optind;
nextchar = NULL;
@ -523,10 +523,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
optarg = NULL;
if (!__getopt_initialized || optind == 0)
if (optind == 0 || !__getopt_initialized)
{
optstring = _getopt_initialize (argc, argv, optstring);
if (optind == 0)
optind = 1; /* Don't scan ARGV[0], the program name. */
optstring = _getopt_initialize (argc, argv, optstring);
__getopt_initialized = 1;
}

View File

@ -22,33 +22,44 @@ if test $# -ne 2; then
exit 1
fi
case $1 in
/*)
# Make both paths absolute.
to=`echo $1 | sed 's%^/%%'`
# A problem with this script is that we must be able to handle symbolic
# links somewhere in the paths of either path. To resolve symlinks we use
# the `pwd' program. But some `pwd' programs are no real programs but
# instead aliases (defined by the user) or builtins (as in bash-2). Both
# kinds have in common that they might not give the correct result. E.g.,
# the builtin in bash-2 returns the path which was used to change to the
# directory and not the real path.
#
# To prevent this problem we make sure the real `pwd' somewhere in the
# path is used. Currently there is only support for bash-2 available.
# If other shells also have problems we have to add more code here.
if test -d $2; then
if test "$BASH_VERSINFO" = "2"; then
unalias pwd
unset pwd
enable -n pwd
fi
# Make both paths absolute.
if test -d $1; then
to=`cd $1 && pwd`
else
temp=`echo $1 | sed 's%/*[^/]*$%%'`
to=`cd $temp && pwd`
to="$to/`echo $1 | sed 's%.*/\([^/][^/]*\)$%\1%'`"
fi
to=`echo $to | sed 's%^/%%'`
if test -d $2; then
from=`echo $2 | sed 's%/*$%%'`
else
else
from=`echo $2 | sed 's%/*[^/]*$%%'`
fi
fi
case "$from" in
/*) from=`echo $from | sed 's%^/*%%'` ;;
?*) from=`cd $from && pwd | sed 's%^/%%'` ;;
*) from=`pwd | sed 's%^/%%'` ;;
esac
;;
*)
to=$1
if test -d $2; then
from=`echo $2 | sed 's%/*$%%'`
else
from=`echo $2 | sed 's%/*[^/]*$%%'`
fi
;;
esac
if test -z "$from"; then
from=`pwd`;
fi
from=`cd $from && pwd | sed 's%^/%%'`
while test -n "$to" && test -n "$from"; do
preto=`echo $to | sed 's%^\([^/]*\)/.*%\1%'`

View File

@ -39,7 +39,7 @@ aux := errlist siglist
distribute := _itoa.h printf-parse.h
tests := tst-printf tstscanf test_rdwr test-popen tstgetln test-fseek \
temptest tst-fileno test-fwrite tst-ungetc \
temptest tst-fileno test-fwrite tst-ungetc tst-ferror \
xbug errnobug \
bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 \
tfformat tiformat tstdiomisc \

41
stdio-common/tst-ferror.c Normal file
View File

@ -0,0 +1,41 @@
#include <stdio.h>
int
main (int argc, char *argv[])
{
char buf[100];
int result = 0;
if (ferror (stdin) != 0)
{
fputs ("error bit set for stdin at startup\n", stdout);
result = 1;
}
if (fgets (buf, sizeof buf, stdin) != buf)
{
fputs ("fgets with existing input has problem\n", stdout);
result = 1;
}
if (ferror (stdin) != 0)
{
fputs ("error bit set for stdin after setup\n", stdout);
result = 1;
}
if (fputc ('a', stdin) != EOF)
{
fputs ("fputc to stdin does not terminate with an error\n", stdout);
result = 1;
}
if (ferror (stdin) == 0)
{
fputs ("error bit not set for stdin after fputc\n", stdout);
result = 1;
}
clearerr (stdin);
if (ferror (stdin) != 0)
{
fputs ("error bit set for stdin after clearerr\n", stdout);
result = 1;
}
return result;
}

View File

@ -0,0 +1 @@
This is a test.

View File

@ -17,6 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <ieee754.h>
#include <stdlib.h>
#include <limits.h>
@ -27,6 +28,8 @@ erand48_r (xsubi, buffer, result)
struct drand48_data *buffer;
double *result;
{
union ieee754_double temp;
/* Compute next state. */
if (__drand48_iterate (xsubi, buffer) < 0)
return -1;
@ -35,9 +38,12 @@ erand48_r (xsubi, buffer, result)
its fractional part so the resulting FP number is [0.0,1.0). */
#if USHRT_MAX == 65535
*result = ((double) xsubi[2] / (1ULL << 48) +
(double) xsubi[1] / (1ULL << 32) +
(double) xsubi[0] / (1ULL << 16));
temp.ieee.negative = 0;
temp.ieee.exponent = IEEE754_DOUBLE_BIAS - 1;
temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
/* Please note the lower 4 bits of mantissa1 are always 0. */
*result = temp.d;
#else
# error Unsupported size of short int
#endif

View File

@ -1,5 +1,5 @@
/* Convert between signal names and numbers.
Copyright (C) 1990, 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
Copyright (C) 1990, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -231,6 +231,9 @@ signame_init ()
#if defined (SIGINFO)
init_sig (SIGINFO, "INFO", "Information request");
#endif
#if defined (SIGNOFP)
init_sig (SIGNOFP, "NOFP", "Floating point co-processor not available");
#endif
}
/* Return the abbreviation for signal NUMBER. */

View File

@ -1,5 +1,5 @@
/* The `struct utmp' type, describing entries in the utmp file. GNU version.
Copyright (C) 1993, 1996 Free Software Foundation, Inc.
Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -100,7 +100,12 @@ struct utmp
};
/* Backwards compatibility hacks. */
#define ut_time ut_tv.tv_sec
#ifndef _NO_UT_TIME
/* We have a problem here: `ut_time' is also used otherwise. Define
_NO_UT_TIME if the compiler complains. */
# define ut_time ut_tv.tv_sec
#endif
#define ut_xtime ut_tv.tv_sec
#define ut_addr ut_addr_v6[0]
/* Tell the user that we have a modern system with UT_HOST, UT_PID,

View File

@ -0,0 +1,32 @@
/* Round argument to nearest integral value according to current rounding
direction.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__rinttol)
fldt 4(%esp)
subl $4, %esp
fistpl (%esp)
popl %eax
ret
END(__rinttol)
weak_alias (__rinttol, rinttol)

View File

@ -0,0 +1,33 @@
/* Round argument to nearest integral value according to current rounding
direction.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__rinttoll)
fldt 4(%esp)
subl $8, %esp
fistpll (%esp)
popl %eax
popl %edx
ret
END(__rinttoll)
weak_alias (__rinttoll, rinttoll)

View File

@ -91,6 +91,6 @@ __cexp (__complex__ double x)
}
weak_alias (__cexp, cexp)
#ifdef NO_LONG_DOUBLE
string_alias (__cexp, __cexpl)
strong_alias (__cexp, __cexpl)
weak_alias (__cexp, cexpl)
#endif

View File

@ -0,0 +1,61 @@
/* Compute complex natural logarithm.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__clog (__complex__ double x)
{
__complex__ double result;
if (__real__ x == 0.0 && __imag__ x == 0.0)
{
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
if (signbit (__imag__ x))
__imag__ result = __copysign (__imag__ result, -1.0);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabs (__real__ x);
}
else if (!__isnan (__real__ x) && !__isnan (__imag__ x))
{
__real__ result = __ieee754_log (__ieee754_hypot (__real__ x,
__imag__ x));
__imag__ result = __ieee754_atan2 (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nan ("");
if (__isinf (__real__ x) || __isinf (__imag__ x))
__real__ result = HUGE_VAL;
else
__real__ result = __nan ("");
}
return result;
}
weak_alias (__clog, clog)
#ifdef NO_LONG_DOUBLE
strong_alias (__clog, __clogl)
weak_alias (__clog, clogl)
#endif

View File

@ -0,0 +1,57 @@
/* Compute complex natural logarithm.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__clogf (__complex__ float x)
{
__complex__ float result;
if (__real__ x == 0.0 && __imag__ x == 0.0)
{
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
if (signbit (__imag__ x))
__imag__ result = __copysignf (__imag__ result, -1.0);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__real__ x);
}
else if (!__isnanf (__real__ x) && !__isnanf (__imag__ x))
{
__real__ result = __ieee754_logf (__ieee754_hypotf (__real__ x,
__imag__ x));
__imag__ result = __ieee754_atan2f (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nanf ("");
if (__isinff (__real__ x) || __isinff (__imag__ x))
__real__ result = HUGE_VALF;
else
__real__ result = __nanf ("");
}
return result;
}
weak_alias (__clogf, clogf)

View File

@ -0,0 +1,57 @@
/* Compute complex natural logarithm.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__clogl (__complex__ long double x)
{
__complex__ long double result;
if (__real__ x == 0.0 && __imag__ x == 0.0)
{
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
if (signbit (__imag__ x))
__imag__ result = __copysignl (__imag__ result, -1.0);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__real__ x);
}
else if (!__isnanl (__real__ x) && !__isnanl (__imag__ x))
{
__real__ result = __ieee754_logl (__ieee754_hypotl (__real__ x,
__imag__ x));
__imag__ result = __ieee754_atan2l (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nanl ("");
if (__isinfl (__real__ x) || __isinfl (__imag__ x))
__real__ result = HUGE_VALL;
else
__real__ result = __nanl ("");
}
return result;
}
weak_alias (__clogl, clogl)

View File

@ -36,9 +36,9 @@ static const long double
#else
static long double
#endif
TWO64[2]={
1.844674407370955161600000e+19, /* 0x403F, 0x00000000, 0x00000000 */
-1.844674407370955161600000e+19, /* 0xC03F, 0x00000000, 0x00000000 */
TWO63[2]={
9.223372036854775808000000e+18, /* 0x403E, 0x00000000, 0x00000000 */
-9.223372036854775808000000e+18 /* 0xC03E, 0x00000000, 0x00000000 */
};
#ifdef __STDC__
@ -61,8 +61,8 @@ TWO64[2]={
i0 &= 0xe0000000;
i0 |= (i1|-i1)&0x80000000;
SET_LDOUBLE_MSW(x,i0);
w = TWO64[sx]+x;
t = w-TWO64[sx];
w = TWO63[sx]+x;
t = w-TWO63[sx];
GET_LDOUBLE_EXP(i0,t);
SET_LDOUBLE_EXP(t,(i0&0x7fff)|(sx<<15));
return t;
@ -80,17 +80,17 @@ TWO64[2]={
s_rintf, too. -- drepper@cygnus.com */
}
}
} else if (j0>63) {
} else if (j0>62) {
if(j0==0x4000) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
i = ((u_int32_t)(0xffffffff))>>(j0-32);
i = ((u_int32_t)(0xffffffff))>>(j0-31);
if((i1&i)==0) return x; /* x is integral */
i>>=1;
if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-32));
if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-31));
}
SET_LDOUBLE_WORDS(x,se,i0,i1);
w = TWO64[sx]+x;
return w-TWO64[sx];
w = TWO63[sx]+x;
return w-TWO63[sx];
}
weak_alias (__rintl, rintl)

View File

@ -0,0 +1,242 @@
/* Round argument to nearest integral value according to current rounding
direction.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <math.h>
#include "math_private.h"
#ifdef NO_LONG_DOUBLE
/* The `long double' is in fact the IEEE `double' type. */
static long double two52[2] =
{
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
long int
__rinttol (long double x)
{
int32_t j0,sx;
u_int32_t i0,i1,i;
long double t, w;
long int result;
EXTRACT_WORDS (i0, i1, x);
sx = i0 >> 31;
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
if (j0 < 20)
{
if (j0 < 0)
{
if (((i0 & 0x7fffffff) | i1) == 0)
/* The number is 0. */
result = 0;
else
{
i1 |= i0;
i0 &= 0xfffe0000;
i0 |= ((i1 | -i1) >> 12) & 0x80000;
SET_HIGH_WORD (x, i0);
w = two52[sx] + x;
t = w - two52[sx];
GET_HIGH_WORD (i0, t);
if ((i0 & 0x7fffffff) >= 0x3fff0000)
result = sx ? -1 : 1;
else
result = 0;
}
}
else
{
u_int32_t i = 0x000fffff >> j0;
if (((i0 & i) | i1) == 0)
{
/* X is not integral. */
i >>= 1;
if (((i0 & i) | i1) != 0)
{
if (j0 == 19)
i1 = 0x40000000;
else
i0 = (i0 & (~i)) | (0x20000 >> j0);
INSERT_WORDS (x, i0, i1);
w = two52[sx] + x;
x = w - two52[sx];
EXTRACT_WORDS (i0, i1, x);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
}
}
result = ((i0 >> (20 - j0)) & 0xfffff) | (0x00100000 >> (20 - j0));
if (sx)
result = -result;
}
}
else if ((unsigned int) j0 < sizeof (long int) * 8 && j0 < 53)
{
i = ((u_int32_t) (0xffffffff)) >> (j0 - 20);
if ((i1 & i) != 0)
{
/* x is not integral. */
i >>= 1;
if ((i1 & i) != 0)
i1 = (i1 & (~i)) | (0x40000000 >> (j0 - 20));
}
INSERT_WORDS (x, i0, i1);
w = two52[sx] + x;
x = w - two52[sx];
EXTRACT_WORDS (i0, i1, x);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
result = i0 | 0x00100000;
if (j0 > 20)
{
result <<= j0 - 20;
result |= i1 >> (52 - j0);
}
if (sx)
result = -result;
}
else
/* Too large. The number is either +-inf or NaN or it is too
large to be effected by rounding. The standard leaves it
undefined what to return when the number is too large to fit in
a `long int'. */
result = (long int) x;
return result;
}
#else
static long double two63[2] =
{
9.223372036854775808000000e+18, /* 0x403E, 0x00000000, 0x00000000 */
-9.223372036854775808000000e+18 /* 0xC03E, 0x00000000, 0x00000000 */
};
long int
__rinttol (long double x)
{
int32_t se,j0,sx;
u_int32_t i0,i1,i;
long int result;
long double w, t;
GET_LDOUBLE_WORDS (se, i0, i1, x);
sx = (se >> 15) & 1;
j0 = (se & 0x7fff) - 0x3fff;
if (j0 < 31)
{
if (j0 < 0)
{
if (((se & 0x7fff) | i0 | i1) == 0)
/* The number is 0. */
result = 0;
else
{
i1 |= i0;
i0 &= 0xe0000000;
i0 |= (i1 | -i1) & 0x80000000;
SET_LDOUBLE_MSW (x, i0);
w = two63[sx] + x;
t = w - two63[sx];
GET_LDOUBLE_EXP (i0, t);
if ((i0 & 0x7fff) >= 0x3fff)
result = sx ? -1 : 1;
else
result = 0;
}
}
else
{
u_int32_t i = 0x7fffffff >> j0;
if (((i0 & i) | i1) == 0)
{
/* X is not integral. */
i >>= 1;
if (((i0 & i) | i1) != 0)
{
if (j0 == 31)
i1 = 0x40000000;
else
i0 = (i0 & (~i)) | (0x20000000 >> j0);
SET_LDOUBLE_WORDS (x, se, i0, i1);
w = two63[sx] + x;
x = w - two63[sx];
GET_LDOUBLE_WORDS (se, i0, i1, x);
sx = (se >> 15) & 1;
j0 = (se & 0x7fff) - 0x3fff;
}
}
result = i0 >> (31 - j0);
}
}
else if ((unsigned int) j0 < sizeof (long int) * 8 && j0 < 64)
{
i = ((u_int32_t) (0xffffffff)) >> (j0 - 31);
if ((i1 & i) != 0)
{
/* x is not integral. */
i >>= 1;
if ((i1 & i) != 0)
i1 = (i1 & (~i)) | (0x40000000 >> (j0 - 31));
}
SET_LDOUBLE_WORDS (x, se, i0, i1);
w = two63[sx] + x;
x = w - two63[sx];
GET_LDOUBLE_WORDS (se, i0, i1, x);
j0 = (se & 0x7fff) - 0x3fff;
result = i0;
if (j0 > 31)
{
result <<= j0 - 31;
result |= i1 >> (63 - j0);
}
}
else
/* Too large. The number is either +-inf or NaN or it is too
large to be effected by rounding. The standard leaves it
undefined what to return when the number is too large to fit in
a `long int'. */
result = (long int) x;
return result;
}
#endif
weak_alias (__rinttol, rinttol)

View File

@ -0,0 +1,242 @@
/* Round argument to nearest integral value according to current rounding
direction.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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 not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <math.h>
#include "math_private.h"
#ifdef NO_LONG_DOUBLE
/* The `long double' is in fact the IEEE `double' type. */
static long double two52[2] =
{
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
long long int
__rinttoll (long double x)
{
int32_t j0,sx;
u_int32_t i0, i1, i;
long double t, w;
long long int result;
EXTRACT_WORDS (i0, i1, x);
sx = i0 >> 31;
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
if (j0 < 20)
{
if (j0 < 0)
{
if (((i0 & 0x7fffffff) | i1) == 0)
/* The number is 0. */
result = 0;
else
{
i1 |= i0;
i0 &= 0xfffe0000;
i0 |= ((i1 | -i1) >> 12) & 0x80000;
SET_HIGH_WORD (x, i0);
w = two52[sx] + x;
t = w - two52[sx];
GET_HIGH_WORD (i0, t);
if ((i0 & 0x7fffffff) >= 0x3fff0000)
result = sx ? -1 : 1;
else
result = 0;
}
}
else
{
u_int32_t i = 0x000fffff >> j0;
if (((i0 & i) | i1) == 0)
{
/* X is not integral. */
i >>= 1;
if (((i0 & i) | i1) != 0)
{
if (j0 == 19)
i1 = 0x40000000;
else
i0 = (i0 & (~i)) | (0x20000 >> j0);
INSERT_WORDS (x, i0, i1);
w = two52[sx] + x;
x = w - two52[sx];
EXTRACT_WORDS (i0, i1, x);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
}
}
result = ((i0 >> (20 - j0)) & 0xfffff) | (0x00100000 >> (20 - j0));
if (sx)
result = -result;
}
}
else if ((unsigned int) j0 < sizeof (long long int) * 8 && j0 < 53)
{
i = ((u_int32_t) (0xffffffff)) >> (j0 - 20);
if ((i1 & i) != 0)
{
/* x is not integral. */
i >>= 1;
if ((i1 & i) != 0)
i1 = (i1 & (~i)) | (0x40000000 >> (j0 - 20));
}
INSERT_WORDS (x, i0, i1);
w = two52[sx] + x;
x = w - two52[sx];
EXTRACT_WORDS (i0, i1, x);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
result = i0 | 0x00100000;
if (j0 > 20)
{
result <<= j0 - 20;
result |= i1 >> (52 - j0);
}
if (sx)
result = -result;
}
else
/* Too large. The number is either +-inf or NaN or it is too
large to be effected by rounding. The standard leaves it
undefined what to return when the number is too large to fit in
a `long int'. */
result = (long long int) x;
return result;
}
#else
static long double two63[2] =
{
9.223372036854775808000000e+18, /* 0x403E, 0x00000000, 0x00000000 */
-9.223372036854775808000000e+18 /* 0xC03E, 0x00000000, 0x00000000 */
};
long long int
__rinttoll (long double x)
{
int32_t se,j0,sx;
u_int32_t i0, i1, i;
long long int result;
long double w, t;
GET_LDOUBLE_WORDS (se, i0, i1, x);
sx = (se >> 15) & 1;
j0 = (se & 0x7fff) - 0x3fff;
if (j0 < 31)
{
if (j0 < 0)
{
if (((se & 0x7fff) | i0 | i1) == 0)
/* The number is 0. */
result = 0;
else
{
i1 |= i0;
i0 &= 0xe0000000;
i0 |= (i1 | -i1) & 0x80000000;
SET_LDOUBLE_MSW (x, i0);
w = two63[sx] + x;
t = w - two63[sx];
GET_LDOUBLE_EXP (i0, t);
if ((i0 & 0x7fff) >= 0x3fff)
result = sx ? -1 : 1;
else
result = 0;
}
}
else
{
u_int32_t i = 0x7fffffff >> j0;
if (((i0 & i) | i1) == 0)
{
/* X is not integral. */
i >>= 1;
if (((i0 & i) | i1) != 0)
{
if (j0 == 31)
i1 = 0x40000000;
else
i0 = (i0 & (~i)) | (0x20000000 >> j0);
SET_LDOUBLE_WORDS (x, se, i0, i1);
w = two63[sx] + x;
x = w - two63[sx];
GET_LDOUBLE_WORDS (se, i0, i1, x);
sx = (se >> 15) & 1;
j0 = (se & 0x7fff) - 0x3fff;
}
}
result = i0 >> (31 - j0);
}
}
else if ((unsigned int) j0 < sizeof (long long int) * 8 && j0 < 64)
{
i = ((u_int32_t) (0xffffffff)) >> (j0 - 31);
if ((i1 & i) != 0)
{
/* x is not integral. */
i >>= 1;
if ((i1 & i) != 0)
i1 = (i1 & (~i)) | (0x40000000 >> (j0 - 31));
}
SET_LDOUBLE_WORDS (x, se, i0, i1);
w = two63[sx] + x;
x = w - two63[sx];
GET_LDOUBLE_WORDS (se, i0, i1, x);
j0 = (se & 0x7fff) - 0x3fff;
result = i0;
if (j0 > 31)
{
result <<= j0 - 31;
result |= i1 >> (63 - j0);
}
}
else
/* Too large. The number is either +-inf or NaN or it is too
large to be effected by rounding. The standard leaves it
undefined what to return when the number is too large to fit in
a `long int'. */
result = (long long int) x;
return result;
}
#endif
weak_alias (__rinttoll, rinttoll)

View File

@ -20,6 +20,7 @@
#define __NETATALK_ATALK_H 1
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/atalk.h>
#define SOL_ATALK 258 /* sockopt level for atalk */

View File

@ -22,8 +22,8 @@
#ifndef _TIME_H
#if (! defined (__need_time_t) && !defined (__need_clock_t) && \
! defined (__need_timespec))
#if (! defined __need_time_t && !defined __need_clock_t && \
! defined __need_timespec)
#define _TIME_H 1
#include <features.h>
@ -56,8 +56,7 @@ __BEGIN_DECLS
#endif /* <time.h> included. */
#if !defined (__clock_t_defined) && \
(defined (_TIME_H) || defined (__need_clock_t))
#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t)
#define __clock_t_defined 1
#include <gnu/types.h>
@ -68,8 +67,7 @@ typedef __clock_t clock_t;
#endif /* clock_t not defined and <time.h> or need clock_t. */
#undef __need_clock_t
#if !defined (__time_t_defined) && \
(defined (_TIME_H) || defined (__need_time_t))
#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)
#define __time_t_defined 1
#include <gnu/types.h>
@ -81,9 +79,9 @@ typedef __time_t time_t;
#undef __need_time_t
#if ! defined (__timespec_defined) && \
((defined (_TIME_H) && defined (__USE_POSIX)) || \
defined (__need_timespec))
#if ! defined __timespec_defined && \
((defined _TIME_H && defined __USE_POSIX) || \
defined __need_timespec)
#define __timespec_defined 1
/* POSIX.4 structure for a time value. This is like a `struct timeval' but
@ -235,7 +233,7 @@ extern long int __tzname_max __P ((void));
extern void tzset __P ((void));
#endif
#if defined(__USE_SVID) || defined(__USE_XOPEN)
#if defined __USE_SVID || defined __USE_XOPEN
extern int daylight;
extern long int timezone;
#endif