update-freadahead 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  2. +++ b/devel/m4/patches/patch-update_freadahead Mon Jul 29 23:39:07 2013 -0400
  3. @@ -0,0 +1,102 @@
  4. +diff -r d1c9a158c955 lib/freadahead.c
  5. +--- lib/freadahead.c Wed Mar 13 20:55:32 2013 +0000
  6. ++++ lib/freadahead.c Wed Mar 13 20:56:08 2013 +0000
  7. +@@ -1,5 +1,5 @@
  8. + /* Retrieve information about a FILE stream.
  9. +- Copyright (C) 2007-2011 Free Software Foundation, Inc.
  10. ++ Copyright (C) 2007-2013 Free Software Foundation, Inc.
  11. +
  12. + This program is free software: you can redistribute it and/or modify
  13. + it under the terms of the GNU General Public License as published by
  14. +@@ -22,6 +22,7 @@
  15. + #include <stdlib.h>
  16. + #include "stdio-impl.h"
  17. +
  18. ++#ifndef HAVE___FREADAHEAD
  19. + size_t
  20. + freadahead (FILE *fp)
  21. + {
  22. +@@ -31,7 +32,7 @@
  23. + return (fp->_IO_read_end - fp->_IO_read_ptr)
  24. + + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
  25. + 0);
  26. +-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
  27. ++#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
  28. + if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
  29. + return 0;
  30. + # if defined __DragonFly__
  31. +@@ -48,6 +49,10 @@
  32. + /* equivalent to
  33. + (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) */
  34. + return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount);
  35. ++#elif defined __minix /* Minix */
  36. ++ if ((fp_->_flags & _IOWRITING) != 0)
  37. ++ return 0;
  38. ++ return fp_->_count;
  39. + #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
  40. + if ((fp_->_flag & _IOWRT) != 0)
  41. + return 0;
  42. +@@ -76,6 +81,10 @@
  43. + return (fp->__pushed_back
  44. + ? fp->__get_limit - fp->__pushback_bufp + 1
  45. + : fp->__get_limit - fp->__bufp);
  46. ++#elif defined EPLAN9 /* Plan9 */
  47. ++ if (fp->state == 4 /* WR */ || fp->rp >= fp->wp)
  48. ++ return 0;
  49. ++ return fp->wp - fp->rp;
  50. + #elif defined SLOW_BUT_NO_HACKS /* users can define this */
  51. + abort ();
  52. + return 0;
  53. +@@ -83,3 +92,4 @@
  54. + #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
  55. + #endif
  56. + }
  57. ++#endif
  58. +diff -r d1c9a158c955 lib/freadahead.h
  59. +--- lib/freadahead.h Wed Mar 13 20:55:32 2013 +0000
  60. ++++ lib/freadahead.h Wed Mar 13 20:56:08 2013 +0000
  61. +@@ -1,5 +1,5 @@
  62. + /* Retrieve information about a FILE stream.
  63. +- Copyright (C) 2007-2011 Free Software Foundation, Inc.
  64. ++ Copyright (C) 2007-2013 Free Software Foundation, Inc.
  65. +
  66. + This program is free software: you can redistribute it and/or modify
  67. + it under the terms of the GNU General Public License as published by
  68. +@@ -17,10 +17,6 @@
  69. + #include <stddef.h>
  70. + #include <stdio.h>
  71. +
  72. +-#ifdef __cplusplus
  73. +-extern "C" {
  74. +-#endif
  75. +-
  76. + /* Assuming the stream STREAM is open for reading:
  77. + Return the number of bytes waiting in the input buffer of STREAM.
  78. + This includes both the bytes that have been read from the underlying input
  79. +@@ -31,8 +27,24 @@
  80. +
  81. + STREAM must not be wide-character oriented. */
  82. +
  83. +-extern size_t freadahead (FILE *stream);
  84. ++#if HAVE___FREADAHEAD || (defined(__linux__) && !defined(__GLIBC__) && !defined(__UCLIBC__)) /* musl libc */
  85. ++#ifndef HAVE___FREADAHEAD
  86. ++#define HAVE___FREADAHEAD 1
  87. ++#endif
  88. +
  89. +-#ifdef __cplusplus
  90. ++# include <stdio_ext.h>
  91. ++# define freadahead(stream) __freadahead (stream)
  92. ++
  93. ++#else
  94. ++
  95. ++# ifdef __cplusplus
  96. ++extern "C" {
  97. ++# endif
  98. ++
  99. ++extern size_t freadahead (FILE *stream) _GL_ATTRIBUTE_PURE;
  100. ++
  101. ++# ifdef __cplusplus
  102. + }
  103. ++# endif
  104. ++
  105. + #endif