mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
1998-10-06 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/bits/in.h: Remove ipv6_mreq which is in netinet/in.h.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
1998-10-06 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/bits/in.h: Remove ipv6_mreq which is in
|
||||||
|
netinet/in.h.
|
||||||
|
|
||||||
1998-10-05 Philip Blundell <philb@gnu.org>
|
1998-10-05 Philip Blundell <philb@gnu.org>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/bits/in.h: Add various new structures
|
* sysdeps/unix/sysv/linux/bits/in.h: Add various new structures
|
||||||
|
@ -573,7 +573,27 @@ case. The function returns @code{-1} if you call it too late, and
|
|||||||
|
|
||||||
The easiest way to arrange to call @code{mcheck} early enough is to use
|
The easiest way to arrange to call @code{mcheck} early enough is to use
|
||||||
the option @samp{-lmcheck} when you link your program; then you don't
|
the option @samp{-lmcheck} when you link your program; then you don't
|
||||||
need to modify your program source at all.
|
need to modify your program source at all. Alternately you might use
|
||||||
|
a debugger to insert a call to @code{mcheck} whenever the program is
|
||||||
|
started, for example these gdb commands will automatically call @code{mcheck}
|
||||||
|
whenever the program starts:
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
(gdb) break main
|
||||||
|
Breakpoint 1, main (argc=2, argv=0xbffff964) at whatever.c:10
|
||||||
|
(gdb) command 1
|
||||||
|
Type commands for when breakpoint 1 is hit, one per line.
|
||||||
|
End with a line saying just "end".
|
||||||
|
>call mcheck(0)
|
||||||
|
>continue
|
||||||
|
>end
|
||||||
|
(gdb) ...
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
|
This will however only work if no initialization function of any object
|
||||||
|
involved calls any of the @code{malloc} functions since @code{mcheck}
|
||||||
|
must be called before the first such function.
|
||||||
|
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun {enum mcheck_status} mprobe (void *@var{pointer})
|
@deftypefun {enum mcheck_status} mprobe (void *@var{pointer})
|
||||||
@ -692,34 +712,86 @@ the @code{free} function was called. This value allows to trace the
|
|||||||
memory consumption of the program.
|
memory consumption of the program.
|
||||||
@end defvar
|
@end defvar
|
||||||
|
|
||||||
|
@comment malloc.h
|
||||||
|
@comment GNU
|
||||||
|
@defvar __memalign_hook
|
||||||
|
The value of this variable is a pointer to function that @code{memalign}
|
||||||
|
uses whenever it is called. You should define this function to look
|
||||||
|
like @code{memalign}; that is, like:
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
void *@var{function} (size_t @var{size}, size_t @var{alignment})
|
||||||
|
@end smallexample
|
||||||
|
@end defvar
|
||||||
|
|
||||||
You must make sure that the function you install as a hook for one of
|
You must make sure that the function you install as a hook for one of
|
||||||
these functions does not call that function recursively without restoring
|
these functions does not call that function recursively without restoring
|
||||||
the old value of the hook first! Otherwise, your program will get stuck
|
the old value of the hook first! Otherwise, your program will get stuck
|
||||||
in an infinite recursion.
|
in an infinite recursion. Before calling the function recursively, one
|
||||||
|
should make sure to restore all the hooks to their previous value. When
|
||||||
|
coming back from the recursive call, all the hooks should be resaved
|
||||||
|
since a hook might modify itself.
|
||||||
|
|
||||||
Here is an example showing how to use @code{__malloc_hook} properly. It
|
Here is an example showing how to use @code{__malloc_hook} and
|
||||||
installs a function that prints out information every time @code{malloc}
|
@code{__free_hook} properly. It installs a function that prints out
|
||||||
is called.
|
information every time @code{malloc} or @code{free} is called. We just
|
||||||
|
assume here that @code{realloc} and @code{memalign} are not used in our
|
||||||
|
program.
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
|
/* Global variables used to hold underlaying hook values. */
|
||||||
static void *(*old_malloc_hook) (size_t);
|
static void *(*old_malloc_hook) (size_t);
|
||||||
|
static void (*old_free_hook) (void*);
|
||||||
|
|
||||||
|
/* Prototypes for our hooks. */
|
||||||
|
static void *my_malloc_hook (size_t);
|
||||||
|
static void my_free_hook(void*);
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
my_malloc_hook (size_t size)
|
my_malloc_hook (size_t size)
|
||||||
@{
|
@{
|
||||||
void *result;
|
void *result;
|
||||||
|
/* Restore all old hooks */
|
||||||
__malloc_hook = old_malloc_hook;
|
__malloc_hook = old_malloc_hook;
|
||||||
|
__free_hook = old_free_hook;
|
||||||
|
/* Call recursively */
|
||||||
result = malloc (size);
|
result = malloc (size);
|
||||||
|
/* Save underlaying hooks */
|
||||||
|
old_malloc_hook = __malloc_hook;
|
||||||
|
old_free_hook = __free_hook;
|
||||||
/* @r{@code{printf} might call @code{malloc}, so protect it too.} */
|
/* @r{@code{printf} might call @code{malloc}, so protect it too.} */
|
||||||
printf ("malloc (%u) returns %p\n", (unsigned int) size, result);
|
printf ("malloc (%u) returns %p\n", (unsigned int) size, result);
|
||||||
|
/* Restore our own hooks */
|
||||||
__malloc_hook = my_malloc_hook;
|
__malloc_hook = my_malloc_hook;
|
||||||
|
__free_hook = my_free_hook;
|
||||||
return result;
|
return result;
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
my_free_hook (void *ptr)
|
||||||
|
@{
|
||||||
|
/* Restore all old hooks */
|
||||||
|
__malloc_hook = old_malloc_hook;
|
||||||
|
__free_hook = old_free_hook;
|
||||||
|
/* Call recursively */
|
||||||
|
free (ptr);
|
||||||
|
/* Save underlaying hooks */
|
||||||
|
old_malloc_hook = __malloc_hook;
|
||||||
|
old_free_hook = __free_hook;
|
||||||
|
/* @r{@code{printf} might call @code{free}, so protect it too.} */
|
||||||
|
printf ("freed pointer %p\n", ptr);
|
||||||
|
/* Restore our own hooks */
|
||||||
|
__malloc_hook = my_malloc_hook;
|
||||||
|
__free_hook = my_free_hook;
|
||||||
|
@}
|
||||||
|
|
||||||
main ()
|
main ()
|
||||||
@{
|
@{
|
||||||
...
|
...
|
||||||
old_malloc_hook = __malloc_hook;
|
old_malloc_hook = __malloc_hook;
|
||||||
|
old_free_hook = __free_hook;
|
||||||
__malloc_hook = my_malloc_hook;
|
__malloc_hook = my_malloc_hook;
|
||||||
|
__free_hook = my_free_hook;
|
||||||
...
|
...
|
||||||
@}
|
@}
|
||||||
@end smallexample
|
@end smallexample
|
||||||
@ -840,6 +912,9 @@ A pointer to a function that @code{realloc} uses whenever it is called.
|
|||||||
@item void (*__free_hook) (void *@var{ptr}, void *@var{caller})
|
@item void (*__free_hook) (void *@var{ptr}, void *@var{caller})
|
||||||
A pointer to a function that @code{free} uses whenever it is called.
|
A pointer to a function that @code{free} uses whenever it is called.
|
||||||
|
|
||||||
|
@item void (*__memalign_hook) (size_t @var{size}, size_t @var{alignment})
|
||||||
|
A pointer to a function that @code{memalign} uses whenever it is called.
|
||||||
|
|
||||||
@item struct mallinfo mallinfo (void)
|
@item struct mallinfo mallinfo (void)
|
||||||
Return information about the current dynamic memory usage.
|
Return information about the current dynamic memory usage.
|
||||||
@xref{Statistics of Malloc}.
|
@xref{Statistics of Malloc}.
|
||||||
@ -1211,13 +1286,11 @@ as an obstack, it must initialize the obstack by calling
|
|||||||
@comment GNU
|
@comment GNU
|
||||||
@deftypefun int obstack_init (struct obstack *@var{obstack-ptr})
|
@deftypefun int obstack_init (struct obstack *@var{obstack-ptr})
|
||||||
Initialize obstack @var{obstack-ptr} for allocation of objects. This
|
Initialize obstack @var{obstack-ptr} for allocation of objects. This
|
||||||
function calls the obstack's @code{obstack_chunk_alloc} function. It
|
function calls the obstack's @code{obstack_chunk_alloc} function. If
|
||||||
returns 0 if @code{obstack_chunk_alloc} returns a null pointer, meaning
|
allocation of memory fails, the function pointed to by
|
||||||
that it is out of memory. Otherwise, it returns 1. If you supply an
|
@code{obstack_alloc_failed_handler} is called. The @code{obstack_init}
|
||||||
@code{obstack_chunk_alloc} function that calls @code{exit}
|
function always returns 1 (Compatibility notice: Former versions of
|
||||||
(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local
|
obstack returned 0 if allocation failed).
|
||||||
Exits}) when out of memory, you can safely ignore the value that
|
|
||||||
@code{obstack_init} returns.
|
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
Here are two examples of how to allocate the space for an obstack and
|
Here are two examples of how to allocate the space for an obstack and
|
||||||
@ -1239,6 +1312,24 @@ struct obstack *myobstack_ptr
|
|||||||
obstack_init (myobstack_ptr);
|
obstack_init (myobstack_ptr);
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
|
@comment obstack.h
|
||||||
|
@comment GNU
|
||||||
|
@defvar obstack_alloc_failed_handler
|
||||||
|
The value of this variable is a pointer to a function that
|
||||||
|
@code{obstack} uses when @code{obstack_chunk_alloc} fails to allocate
|
||||||
|
memory. The default action is to print a message and abort.
|
||||||
|
You should supply a function that either calls @code{exit}
|
||||||
|
(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local
|
||||||
|
Exits}) and doesn't return.
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
void my_obstack_alloc_failed (void)
|
||||||
|
@dots{}
|
||||||
|
obstack_alloc_failed_handler = &my_obstack_alloc_failed;
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
|
@end defvar
|
||||||
|
|
||||||
@node Allocation in an Obstack
|
@node Allocation in an Obstack
|
||||||
@subsection Allocation in an Obstack
|
@subsection Allocation in an Obstack
|
||||||
@cindex allocation (obstacks)
|
@cindex allocation (obstacks)
|
||||||
@ -1256,13 +1347,9 @@ object which represents the obstack. Each obstack function or macro
|
|||||||
requires you to specify an @var{obstack-ptr} as the first argument.
|
requires you to specify an @var{obstack-ptr} as the first argument.
|
||||||
|
|
||||||
This function calls the obstack's @code{obstack_chunk_alloc} function if
|
This function calls the obstack's @code{obstack_chunk_alloc} function if
|
||||||
it needs to allocate a new chunk of memory; it returns a null pointer if
|
it needs to allocate a new chunk of memory; it calls
|
||||||
@code{obstack_chunk_alloc} returns one. In that case, it has not
|
@code{obstack_alloc_failed_handler} if allocation of memory by
|
||||||
changed the amount of memory allocated in the obstack. If you supply an
|
@code{obstack_chunk_alloc} failed.
|
||||||
@code{obstack_chunk_alloc} function that calls @code{exit}
|
|
||||||
(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local
|
|
||||||
Exits}) when out of memory, then @code{obstack_alloc} will never return
|
|
||||||
a null pointer.
|
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
For example, here is a function that allocates a copy of a string @var{str}
|
For example, here is a function that allocates a copy of a string @var{str}
|
||||||
@ -1288,8 +1375,9 @@ To allocate a block with specified contents, use the function
|
|||||||
@comment GNU
|
@comment GNU
|
||||||
@deftypefun {void *} obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
|
@deftypefun {void *} obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
|
||||||
This allocates a block and initializes it by copying @var{size}
|
This allocates a block and initializes it by copying @var{size}
|
||||||
bytes of data starting at @var{address}. It can return a null pointer
|
bytes of data starting at @var{address}. It calls
|
||||||
under the same conditions as @code{obstack_alloc}.
|
@code{obstack_alloc_failed_handler} if allocation of memory by
|
||||||
|
@code{obstack_chunk_alloc} failed.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@comment obstack.h
|
@comment obstack.h
|
||||||
|
@ -84,13 +84,6 @@ struct ip_mreqn
|
|||||||
int imr_ifindex; /* Interface index */
|
int imr_ifindex; /* Interface index */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* As above but for IPv6. */
|
|
||||||
struct ipv6_mreq
|
|
||||||
{
|
|
||||||
struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address of group */
|
|
||||||
int ipv6mr_ifindex; /* local IPv6 address of interface */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
|
/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
|
||||||
The first word in the comment at the right is the data type used;
|
The first word in the comment at the right is the data type used;
|
||||||
"bool" means a boolean value stored in an `int'. */
|
"bool" means a boolean value stored in an `int'. */
|
||||||
|
Reference in New Issue
Block a user