100-fix_cross_rpcgen.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --- a/libc/sunrpc/proto.h
  2. +++ b/libc/sunrpc/proto.h
  3. @@ -56,12 +56,14 @@ void add_type(int len, const char *type)
  4. $build's C library and $host's GLIBC. */
  5. #ifdef _CROSS_RPCGEN_
  6. +#undef stpcpy
  7. +
  8. /* Rather then defining _GNU_SOURCE before including $build's <string.h>
  9. we just declare stpcpy here. */
  10. extern char *stpcpy (char *, const char *);
  11. -/* Use $build's i18n support as we can't use $host's. */
  12. -#define _(X) (gettext (X))
  13. +/* Do not use i18n support */
  14. +#define _(X) (X)
  15. /* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
  16. that rpcgen generates. The proper fix would be to rename all those checks
  17. --- a/libc/sunrpc/rpc/types.h
  18. +++ b/libc/sunrpc/rpc/types.h
  19. @@ -70,18 +70,23 @@ typedef unsigned long rpcport_t;
  20. #endif
  21. #ifndef __u_char_defined
  22. -typedef __u_char u_char;
  23. -typedef __u_short u_short;
  24. -typedef __u_int u_int;
  25. -typedef __u_long u_long;
  26. -typedef __quad_t quad_t;
  27. -typedef __u_quad_t u_quad_t;
  28. -typedef __fsid_t fsid_t;
  29. +typedef unsigned char u_char;
  30. +typedef unsigned short u_short;
  31. +typedef unsigned int u_int;
  32. +typedef unsigned long u_long;
  33. +#if __WORDSIZE == 64
  34. +typedef long int quad_t;
  35. +typedef unsigned long int u_quad_t;
  36. +#elif defined __GLIBC_HAVE_LONG_LONG
  37. +typedef long long int quad_t;
  38. +typedef unsigned long long int u_quad_t;
  39. +#endif
  40. +typedef u_quad_t fsid_t;
  41. # define __u_char_defined
  42. #endif
  43. -#ifndef __daddr_t_defined
  44. -typedef __daddr_t daddr_t;
  45. -typedef __caddr_t caddr_t;
  46. +#if !defined(__daddr_t_defined) && defined(linux)
  47. +typedef long int daddr_t;
  48. +typedef char *caddr_t;
  49. # define __daddr_t_defined
  50. #endif
  51. --- a/libc/sunrpc/rpc_main.c
  52. +++ b/libc/sunrpc/rpc_main.c
  53. @@ -997,9 +997,10 @@ mkfile_output (struct commandline *cmd)
  54. abort ();
  55. temp = rindex (cmd->infile, '.');
  56. cp = stpcpy (mkfilename, "Makefile.");
  57. - if (temp != NULL)
  58. - *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
  59. - else
  60. + if (temp != NULL) {
  61. + strncpy(cp, cmd->infile, temp - cmd->infile);
  62. + cp[temp - cmd->infile - 1] = 0;
  63. + } else
  64. stpcpy (cp, cmd->infile);
  65. }