summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
committerRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
commit7cd274587760436effbfce65cfdbd51f761acd67 (patch)
tree8620654b8197c81aded8a206680e53b4294baccf /stdlib
parentaa29d418cf3ee21f906247b6ab49e8aab6fd19dc (diff)
Updated to fedora-glibc-2_3-20050216T1256
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile28
-rw-r--r--stdlib/fmtmsg.c23
-rw-r--r--stdlib/random_r.c9
-rw-r--r--stdlib/tst-fmtmsg.c32
4 files changed, 62 insertions, 30 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 5f4675033e..24db960044 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -61,10 +61,15 @@ distribute := exit.h grouping.h abort-instr.h isomac.c tst-fmtmsg.sh \
test-srcs := tst-fmtmsg
tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
test-canon test-canon2 tst-strtoll tst-environ \
- tst-xpg-basename tst-random tst-bsearch tst-limits \
- tst-rand48 bug-strtod tst-setcontext test-a64l tst-qsort \
- tst-system testmb2
+ tst-xpg-basename tst-random tst-random2 tst-bsearch \
+ tst-limits tst-rand48 bug-strtod tst-setcontext \
+ test-a64l tst-qsort tst-system testmb2
+include ../Makeconfig
+
+ifeq ($(build-shared),yes)
+tests += tst-putenv
+endif
# Several mpn functions from GNU MP are used by the strtod function.
mpn-routines := inlines add_n addmul_1 cmp divmod_1 divrem udiv_qrnnd \
@@ -75,18 +80,21 @@ routines := $(strip $(routines) $(mpn-routines)) \
dbl2mpn ldbl2mpn \
mpn2flt mpn2dbl mpn2ldbl
aux += fpioconst mp_clz_tab
-distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h
+distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h \
+ tst-putenvmod.c
+
+tests-extras += tst-putenvmod
+extra-objs += tst-putenvmod.os
-generated += isomac isomac.out
+generated += isomac isomac.out tst-putenvmod.so
CFLAGS-bsearch.c = $(uses-callbacks)
CFLAGS-msort.c = $(uses-callbacks)
CFLAGS-qsort.c = $(uses-callbacks)
CFLAGS-system.c = -fexceptions
+CFLAGS-system.os = -fomit-frame-pointer
CFLAGS-fmtmsg.c = -fexceptions
-include ../Makeconfig
-
ifneq (,$(filter %REENTRANT, $(defines)))
CFLAGS-strfmon.c = -D_IO_MTSAFE_IO
CFLAGS-strfmon_l.c = -D_IO_MTSAFE_IO
@@ -124,3 +132,9 @@ $(objpfx)isomac: isomac.c
$(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/
+
+$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
+
+$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os
+ $(build-module)
+CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 2ab97b7d90..7505e4c78d 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -316,7 +316,7 @@ internal_addseverity (int severity, const char *string)
int result = MM_OK;
/* First see if there is already a record for the severity level. */
- for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp-> next)
+ for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp->next)
if (runp->severity == severity)
break;
else
@@ -324,9 +324,6 @@ internal_addseverity (int severity, const char *string)
if (runp != NULL)
{
- /* Release old string. */
- free ((char *) runp->string);
-
if (string != NULL)
/* Change the string. */
runp->string = string;
@@ -367,34 +364,17 @@ int
addseverity (int severity, const char *string)
{
int result;
- const char *new_string;
/* Prevent illegal SEVERITY values. */
if (severity <= MM_INFO)
return MM_NOTOK;
- if (string == NULL)
- /* We want to remove the severity class. */
- new_string = NULL;
- else
- {
- new_string = __strdup (string);
-
- if (new_string == NULL)
- /* Allocation failed or illegal value. */
- return MM_NOTOK;
- }
-
/* Protect the global data. */
__libc_lock_lock (lock);
/* Do the real work. */
result = internal_addseverity (severity, string);
- if (result != MM_OK)
- /* Free the allocated string. */
- free ((char *) new_string);
-
/* Release the lock. */
__libc_lock_unlock (lock);
@@ -411,7 +391,6 @@ libc_freeres_fn (free_mem)
{
/* This is data we have to release. */
struct severity_info *here = runp;
- free ((char *) runp->string);
runp = runp->next;
free (here);
}
diff --git a/stdlib/random_r.c b/stdlib/random_r.c
index 09677e6077..e955ea576a 100644
--- a/stdlib/random_r.c
+++ b/stdlib/random_r.c
@@ -240,10 +240,19 @@ __initstate_r (seed, arg_state, n, buf)
int degree;
int separation;
int32_t *state;
+ int old_type;
+ int32_t *old_state;
if (buf == NULL)
goto fail;
+ old_type = buf->rand_type;
+ old_state = buf->state;
+ if (old_type == TYPE_0)
+ old_state[-1] = TYPE_0;
+ else
+ old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type;
+
if (n >= BREAK_3)
type = n < BREAK_4 ? TYPE_3 : TYPE_4;
else if (n < BREAK_1)
diff --git a/stdlib/tst-fmtmsg.c b/stdlib/tst-fmtmsg.c
index d5369bda62..c3748d64d5 100644
--- a/stdlib/tst-fmtmsg.c
+++ b/stdlib/tst-fmtmsg.c
@@ -1,6 +1,8 @@
#include <fmtmsg.h>
#include <mcheck.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define MM_TEST 10
@@ -12,11 +14,13 @@ main (void)
mtrace ();
- if (addseverity (MM_TEST, "TEST") != MM_OK)
+ char TEST[] = "ABCD";
+ if (addseverity (MM_TEST, TEST) != MM_OK)
{
puts ("addseverity failed");
result = 1;
}
+ strcpy (TEST, "TEST");
if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_HALT, "halt",
"should print message for MM_HALT", "GLIBC:tst-fmtmsg:1")
@@ -48,5 +52,31 @@ main (void)
!= MM_OK)
result = 1;
+ if (addseverity (MM_TEST, NULL) != MM_OK)
+ {
+ puts ("second addseverity failed");
+ result = 1;
+ }
+
+ if (addseverity (MM_TEST, NULL) != MM_NOTOK)
+ {
+ puts ("third addseverity unexpectedly succeeded");
+ result = 1;
+ }
+
+ char *p = strdup ("TEST2");
+ if (addseverity (MM_TEST, p) != MM_OK)
+ {
+ puts ("fourth addseverity failed");
+ result = 1;
+ }
+ if (addseverity (MM_TEST, "TEST3") != MM_OK)
+ {
+ puts ("fifth addseverity failed");
+ result = 1;
+ }
+
+ free (p);
+
return result;
}