From 085560da45f0b2ca6e4af59606b9cab9f4c8e037 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Fri, 1 Jun 2012 01:01:57 +0000 Subject: [PATCH] Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(), and valloc() are not in the current version, while posix_memalign() mkstemp(), and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'. ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@ --- src/include/stdlib.h | 51 ++++++++++++++++++++++++++---------- src/lib/libc/stdlib/ecvt.3 | 9 ++++--- src/lib/libc/stdlib/random.3 | 6 ++--- src/lib/libc/stdlib/random.c | 4 +-- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/include/stdlib.h b/src/include/stdlib.h index bbd57544..34eb1870 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.49 2011/07/03 18:51:01 jsg Exp $ */ +/* $OpenBSD: stdlib.h,v 1.50 2012/06/01 01:01:57 guenther Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -117,17 +117,13 @@ void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); void *calloc(size_t, size_t); div_t div(int, int); -char *ecvt(double, int, int *, int *); __dead void exit(int); __dead void _Exit(int); -char *fcvt(double, int, int *, int *); void free(void *); -char *gcvt(double, int, char *); char *getenv(const char *); long labs(long); ldiv_t ldiv(long, long); void *malloc(size_t); -int posix_memalign(void **, size_t, size_t); void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); int rand(void); void *realloc(void *, size_t); @@ -151,8 +147,7 @@ size_t wcstombs(char *, const wchar_t *, size_t); /* * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 */ -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500 || \ - defined(_REENTRANT) +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || defined(_REENTRANT) int rand_r(unsigned int *); #endif @@ -170,6 +165,19 @@ void srand48(long); int putenv(char *); #endif +/* + * XSI functions marked LEGACY in IEEE Std 1003.1-2001 (POSIX) and + * removed in IEEE Std 1003.1-2008 + */ +#if __BSD_VISIBLE || __XPG_VISIBLE < 700 +char *ecvt(double, int, int *, int *); +char *fcvt(double, int, int *, int *); +char *gcvt(double, int, char *); +#if __BSD_VISIBLE || __XPG_VISIBLE >= 420 +char *mktemp(char *); +#endif +#endif /* __BSD_VISIBLE || __XPG_VISIBLE < 700 */ + #if __BSD_VISIBLE || __XPG_VISIBLE >= 420 long a64l(const char *); char *l64a(long); @@ -177,21 +185,29 @@ char *l64a(long); char *initstate(unsigned int, char *, size_t) __attribute__((__bounded__ (__string__,2,3))); long random(void); -char *setstate(const char *); +char *setstate(char *); void srandom(unsigned int); -int mkstemp(char *); -char *mktemp(char *); - char *realpath(const char *, char *); int setkey(const char *); +/* + * XSI functions marked LEGACY in XPG5 and removed in IEEE Std 1003.1-2001 + */ +#if __BSD_VISIBLE || __XPG_VISIBLE < 600 int ttyslot(void); - void *valloc(size_t); /* obsoleted by malloc() */ +#endif #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */ +/* + * 4.4BSD, then XSI in XPG4.2, then added to POSIX base in IEEE Std 1003.1-2008 + */ +#if __BSD_VISIBLE || __XPG_VISIBLE >= 420 || __POSIX_VISIBLE >= 200809 +int mkstemp(char *); +#endif + /* * ISO C99 */ @@ -211,11 +227,19 @@ unsigned long long /* * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) */ -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE >= 600 +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 +int posix_memalign(void **, size_t, size_t); int setenv(const char *, const char *, int); int unsetenv(const char *); #endif +/* + * The Open Group Base Specifications, Issue 7; IEEE Std 1003.1-2008 (POSIX) + */ +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +char *mkdtemp(char *); +#endif + #if __BSD_VISIBLE void *alloca(size_t); @@ -247,7 +271,6 @@ int getsubopt(char **, char * const *, char **); extern char *suboptarg; /* getsubopt(3) external variable */ #endif /* _GETOPT_DEFINED_ */ -char *mkdtemp(char *); int mkstemps(char *, int); int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); diff --git a/src/lib/libc/stdlib/ecvt.3 b/src/lib/libc/stdlib/ecvt.3 index 2f107e11..0191a342 100644 --- a/src/lib/libc/stdlib/ecvt.3 +++ b/src/lib/libc/stdlib/ecvt.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ecvt.3,v 1.9 2010/04/01 17:06:55 jmc Exp $ +.\" $OpenBSD: ecvt.3,v 1.10 2012/06/01 01:01:57 guenther Exp $ .\" .\" Copyright (c) 2002 Todd C. Miller .\" @@ -18,7 +18,7 @@ .\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" -.Dd $Mdocdate: April 1 2010 $ +.Dd $Mdocdate: June 1 2012 $ .Dt ECVT 3 .Os .Sh NAME @@ -148,7 +148,10 @@ The and .Fn gcvt functions conform to -.St -p1003.1-2001 . +.St -p1003.1-2001 ; +as of +.St -p1003.1-2008 +they are no longer a part of the standard. .Sh CAVEATS The .Fn ecvt diff --git a/src/lib/libc/stdlib/random.3 b/src/lib/libc/stdlib/random.3 index ed05df16..84756bb3 100644 --- a/src/lib/libc/stdlib/random.3 +++ b/src/lib/libc/stdlib/random.3 @@ -25,9 +25,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: random.3,v 1.19 2007/05/31 19:19:31 jmc Exp $ +.\" $OpenBSD: random.3,v 1.20 2012/06/01 01:01:57 guenther Exp $ .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 1 2012 $ .Dt RANDOM 3 .Os .Sh NAME @@ -48,7 +48,7 @@ .Ft char * .Fn initstate "unsigned int seed" "char *state" "size_t n" .Ft char * -.Fn setstate "const char *state" +.Fn setstate "char *state" .Sh DESCRIPTION The .Fn random diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c index 5a9a7c33..9c5b9d0f 100644 --- a/src/lib/libc/stdlib/random.c +++ b/src/lib/libc/stdlib/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.16 2012/03/21 12:36:49 millert Exp $ */ +/* $OpenBSD: random.c,v 1.17 2012/06/01 01:01:57 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. @@ -326,7 +326,7 @@ initstate(u_int seed, char *arg_state, size_t n) * Returns a pointer to the old state information. */ char * -setstate(const char *arg_state) +setstate(char *arg_state) { int32_t *new_state = (int32_t *)arg_state; int32_t type = new_state[0] % MAX_TYPES;