aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib.in.h
diff options
context:
space:
mode:
authorPaul Eggert2012-05-26 16:14:36 -0700
committerPaul Eggert2012-05-26 16:14:36 -0700
commitcaf8a9b2b301aba06735d403317b75b41df59bfe (patch)
treebfafb3cc0cf8a2f2394b4ed721e7c3d4891b78ab /lib/stdlib.in.h
parentfe453991eafc32a890297a2003ac532b9f579f92 (diff)
downloademacs-caf8a9b2b301aba06735d403317b75b41df59bfe.tar.gz
emacs-caf8a9b2b301aba06735d403317b75b41df59bfe.zip
Merge from gnulib.
Fixes: debbugs:11527
Diffstat (limited to 'lib/stdlib.in.h')
-rw-r--r--lib/stdlib.in.h190
1 files changed, 178 insertions, 12 deletions
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 047fac18b83..b546133c3af 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2011 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2012 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -49,6 +49,11 @@
49# include <sys/loadavg.h> 49# include <sys/loadavg.h>
50#endif 50#endif
51 51
52/* Native Windows platforms declare mktemp() in <io.h>. */
53#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
54# include <io.h>
55#endif
56
52#if @GNULIB_RANDOM_R@ 57#if @GNULIB_RANDOM_R@
53 58
54/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included 59/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
@@ -58,7 +63,7 @@
58# include <random.h> 63# include <random.h>
59# endif 64# endif
60 65
61# if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@ 66# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
62# include <stdint.h> 67# include <stdint.h>
63# endif 68# endif
64 69
@@ -89,6 +94,14 @@ struct random_data
89# include <unistd.h> 94# include <unistd.h>
90#endif 95#endif
91 96
97/* The __attribute__ feature is available in gcc versions 2.5 and later.
98 The attribute __pure__ was added in gcc 2.96. */
99#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
100# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
101#else
102# define _GL_ATTRIBUTE_PURE /* empty */
103#endif
104
92/* The definition of _Noreturn is copied here. */ 105/* The definition of _Noreturn is copied here. */
93 106
94/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 107/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -133,7 +146,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
133/* Parse a signed decimal integer. 146/* Parse a signed decimal integer.
134 Returns the value of the integer. Errors are not detected. */ 147 Returns the value of the integer. Errors are not detected. */
135# if !@HAVE_ATOLL@ 148# if !@HAVE_ATOLL@
136_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1))); 149_GL_FUNCDECL_SYS (atoll, long long, (const char *string)
150 _GL_ATTRIBUTE_PURE
151 _GL_ARG_NONNULL ((1)));
137# endif 152# endif
138_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); 153_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
139_GL_CXXALIASWARN (atoll); 154_GL_CXXALIASWARN (atoll);
@@ -247,7 +262,7 @@ _GL_CXXALIASWARN (grantpt);
247#elif defined GNULIB_POSIXCHECK 262#elif defined GNULIB_POSIXCHECK
248# undef grantpt 263# undef grantpt
249# if HAVE_RAW_DECL_GRANTPT 264# if HAVE_RAW_DECL_GRANTPT
250_GL_WARN_ON_USE (ptsname, "grantpt is not portable - " 265_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
251 "use gnulib module grantpt for portability"); 266 "use gnulib module grantpt for portability");
252# endif 267# endif
253#endif 268#endif
@@ -423,6 +438,22 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
423# endif 438# endif
424#endif 439#endif
425 440
441#if @GNULIB_POSIX_OPENPT@
442/* Return an FD open to the master side of a pseudo-terminal. Flags should
443 include O_RDWR, and may also include O_NOCTTY. */
444# if !@HAVE_POSIX_OPENPT@
445_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
446# endif
447_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
448_GL_CXXALIASWARN (posix_openpt);
449#elif defined GNULIB_POSIXCHECK
450# undef posix_openpt
451# if HAVE_RAW_DECL_POSIX_OPENPT
452_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
453 "use gnulib module posix_openpt for portability");
454# endif
455#endif
456
426#if @GNULIB_PTSNAME@ 457#if @GNULIB_PTSNAME@
427/* Return the pathname of the pseudo-terminal slave associated with 458/* Return the pathname of the pseudo-terminal slave associated with
428 the master FD is open on, or NULL on errors. */ 459 the master FD is open on, or NULL on errors. */
@@ -439,6 +470,32 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
439# endif 470# endif
440#endif 471#endif
441 472
473#if @GNULIB_PTSNAME_R@
474/* Set the pathname of the pseudo-terminal slave associated with
475 the master FD is open on and return 0, or set errno and return
476 non-zero on errors. */
477# if @REPLACE_PTSNAME_R@
478# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479# undef ptsname_r
480# define ptsname_r rpl_ptsname_r
481# endif
482_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
483_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
484# else
485# if !@HAVE_PTSNAME_R@
486_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
487# endif
488_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
489# endif
490_GL_CXXALIASWARN (ptsname_r);
491#elif defined GNULIB_POSIXCHECK
492# undef ptsname_r
493# if HAVE_RAW_DECL_PTSNAME_R
494_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
495 "use gnulib module ptsname_r for portability");
496# endif
497#endif
498
442#if @GNULIB_PUTENV@ 499#if @GNULIB_PUTENV@
443# if @REPLACE_PUTENV@ 500# if @REPLACE_PUTENV@
444# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 501# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -462,12 +519,83 @@ _GL_CXXALIASWARN (putenv);
462# endif 519# endif
463#endif 520#endif
464 521
522
523#if @GNULIB_RANDOM@
524# if !@HAVE_RANDOM@
525_GL_FUNCDECL_SYS (random, long, (void));
526# endif
527_GL_CXXALIAS_SYS (random, long, (void));
528_GL_CXXALIASWARN (random);
529#elif defined GNULIB_POSIXCHECK
530# undef random
531# if HAVE_RAW_DECL_RANDOM
532_GL_WARN_ON_USE (random, "random is unportable - "
533 "use gnulib module random for portability");
534# endif
535#endif
536
537#if @GNULIB_RANDOM@
538# if !@HAVE_RANDOM@
539_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
540# endif
541_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
542_GL_CXXALIASWARN (srandom);
543#elif defined GNULIB_POSIXCHECK
544# undef srandom
545# if HAVE_RAW_DECL_SRANDOM
546_GL_WARN_ON_USE (srandom, "srandom is unportable - "
547 "use gnulib module random for portability");
548# endif
549#endif
550
551#if @GNULIB_RANDOM@
552# if !@HAVE_RANDOM@
553_GL_FUNCDECL_SYS (initstate, char *,
554 (unsigned int seed, char *buf, size_t buf_size)
555 _GL_ARG_NONNULL ((2)));
556# endif
557_GL_CXXALIAS_SYS (initstate, char *,
558 (unsigned int seed, char *buf, size_t buf_size));
559_GL_CXXALIASWARN (initstate);
560#elif defined GNULIB_POSIXCHECK
561# undef initstate
562# if HAVE_RAW_DECL_INITSTATE_R
563_GL_WARN_ON_USE (initstate, "initstate is unportable - "
564 "use gnulib module random for portability");
565# endif
566#endif
567
568#if @GNULIB_RANDOM@
569# if !@HAVE_RANDOM@
570_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
571# endif
572_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
573_GL_CXXALIASWARN (setstate);
574#elif defined GNULIB_POSIXCHECK
575# undef setstate
576# if HAVE_RAW_DECL_SETSTATE_R
577_GL_WARN_ON_USE (setstate, "setstate is unportable - "
578 "use gnulib module random for portability");
579# endif
580#endif
581
582
465#if @GNULIB_RANDOM_R@ 583#if @GNULIB_RANDOM_R@
466# if !@HAVE_RANDOM_R@ 584# if @REPLACE_RANDOM_R@
585# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
586# undef random_r
587# define random_r rpl_random_r
588# endif
589_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
590 _GL_ARG_NONNULL ((1, 2)));
591_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
592# else
593# if !@HAVE_RANDOM_R@
467_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) 594_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
468 _GL_ARG_NONNULL ((1, 2))); 595 _GL_ARG_NONNULL ((1, 2)));
469# endif 596# endif
470_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); 597_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
598# endif
471_GL_CXXALIASWARN (random_r); 599_GL_CXXALIASWARN (random_r);
472#elif defined GNULIB_POSIXCHECK 600#elif defined GNULIB_POSIXCHECK
473# undef random_r 601# undef random_r
@@ -478,13 +606,25 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
478#endif 606#endif
479 607
480#if @GNULIB_RANDOM_R@ 608#if @GNULIB_RANDOM_R@
481# if !@HAVE_RANDOM_R@ 609# if @REPLACE_RANDOM_R@
610# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
611# undef srandom_r
612# define srandom_r rpl_srandom_r
613# endif
614_GL_FUNCDECL_RPL (srandom_r, int,
615 (unsigned int seed, struct random_data *rand_state)
616 _GL_ARG_NONNULL ((2)));
617_GL_CXXALIAS_RPL (srandom_r, int,
618 (unsigned int seed, struct random_data *rand_state));
619# else
620# if !@HAVE_RANDOM_R@
482_GL_FUNCDECL_SYS (srandom_r, int, 621_GL_FUNCDECL_SYS (srandom_r, int,
483 (unsigned int seed, struct random_data *rand_state) 622 (unsigned int seed, struct random_data *rand_state)
484 _GL_ARG_NONNULL ((2))); 623 _GL_ARG_NONNULL ((2)));
485# endif 624# endif
486_GL_CXXALIAS_SYS (srandom_r, int, 625_GL_CXXALIAS_SYS (srandom_r, int,
487 (unsigned int seed, struct random_data *rand_state)); 626 (unsigned int seed, struct random_data *rand_state));
627# endif
488_GL_CXXALIASWARN (srandom_r); 628_GL_CXXALIASWARN (srandom_r);
489#elif defined GNULIB_POSIXCHECK 629#elif defined GNULIB_POSIXCHECK
490# undef srandom_r 630# undef srandom_r
@@ -495,15 +635,29 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
495#endif 635#endif
496 636
497#if @GNULIB_RANDOM_R@ 637#if @GNULIB_RANDOM_R@
498# if !@HAVE_RANDOM_R@ 638# if @REPLACE_RANDOM_R@
639# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
640# undef initstate_r
641# define initstate_r rpl_initstate_r
642# endif
643_GL_FUNCDECL_RPL (initstate_r, int,
644 (unsigned int seed, char *buf, size_t buf_size,
645 struct random_data *rand_state)
646 _GL_ARG_NONNULL ((2, 4)));
647_GL_CXXALIAS_RPL (initstate_r, int,
648 (unsigned int seed, char *buf, size_t buf_size,
649 struct random_data *rand_state));
650# else
651# if !@HAVE_RANDOM_R@
499_GL_FUNCDECL_SYS (initstate_r, int, 652_GL_FUNCDECL_SYS (initstate_r, int,
500 (unsigned int seed, char *buf, size_t buf_size, 653 (unsigned int seed, char *buf, size_t buf_size,
501 struct random_data *rand_state) 654 struct random_data *rand_state)
502 _GL_ARG_NONNULL ((2, 4))); 655 _GL_ARG_NONNULL ((2, 4)));
503# endif 656# endif
504_GL_CXXALIAS_SYS (initstate_r, int, 657_GL_CXXALIAS_SYS (initstate_r, int,
505 (unsigned int seed, char *buf, size_t buf_size, 658 (unsigned int seed, char *buf, size_t buf_size,
506 struct random_data *rand_state)); 659 struct random_data *rand_state));
660# endif
507_GL_CXXALIASWARN (initstate_r); 661_GL_CXXALIASWARN (initstate_r);
508#elif defined GNULIB_POSIXCHECK 662#elif defined GNULIB_POSIXCHECK
509# undef initstate_r 663# undef initstate_r
@@ -514,13 +668,25 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
514#endif 668#endif
515 669
516#if @GNULIB_RANDOM_R@ 670#if @GNULIB_RANDOM_R@
517# if !@HAVE_RANDOM_R@ 671# if @REPLACE_RANDOM_R@
672# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673# undef setstate_r
674# define setstate_r rpl_setstate_r
675# endif
676_GL_FUNCDECL_RPL (setstate_r, int,
677 (char *arg_state, struct random_data *rand_state)
678 _GL_ARG_NONNULL ((1, 2)));
679_GL_CXXALIAS_RPL (setstate_r, int,
680 (char *arg_state, struct random_data *rand_state));
681# else
682# if !@HAVE_RANDOM_R@
518_GL_FUNCDECL_SYS (setstate_r, int, 683_GL_FUNCDECL_SYS (setstate_r, int,
519 (char *arg_state, struct random_data *rand_state) 684 (char *arg_state, struct random_data *rand_state)
520 _GL_ARG_NONNULL ((1, 2))); 685 _GL_ARG_NONNULL ((1, 2)));
521# endif 686# endif
522_GL_CXXALIAS_SYS (setstate_r, int, 687_GL_CXXALIAS_SYS (setstate_r, int,
523 (char *arg_state, struct random_data *rand_state)); 688 (char *arg_state, struct random_data *rand_state));
689# endif
524_GL_CXXALIASWARN (setstate_r); 690_GL_CXXALIASWARN (setstate_r);
525#elif defined GNULIB_POSIXCHECK 691#elif defined GNULIB_POSIXCHECK
526# undef setstate_r 692# undef setstate_r