1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-24 05:34:36 +02:00

eglibc: fix portability issues rpcgen and zic, fixes compile on darwin

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27359 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2011-07-02 09:46:39 +00:00
parent 01b3fa0465
commit 0b9131c9b9
4 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,71 @@
--- a/libc/sunrpc/proto.h
+++ b/libc/sunrpc/proto.h
@@ -56,12 +56,14 @@ void add_type(int len, const char *type)
$build's C library and $host's GLIBC. */
#ifdef _CROSS_RPCGEN_
+#undef stpcpy
+
/* Rather then defining _GNU_SOURCE before including $build's <string.h>
we just declare stpcpy here. */
extern char *stpcpy (char *, const char *);
-/* Use $build's i18n support as we can't use $host's. */
-#define _(X) (gettext (X))
+/* Do not use i18n support */
+#define _(X) (X)
/* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
that rpcgen generates. The proper fix would be to rename all those checks
--- a/libc/sunrpc/rpc/types.h
+++ b/libc/sunrpc/rpc/types.h
@@ -69,18 +69,23 @@ typedef unsigned long rpcport_t;
#endif
#ifndef __u_char_defined
-typedef __u_char u_char;
-typedef __u_short u_short;
-typedef __u_int u_int;
-typedef __u_long u_long;
-typedef __quad_t quad_t;
-typedef __u_quad_t u_quad_t;
-typedef __fsid_t fsid_t;
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+#if __WORDSIZE == 64
+typedef long int quad_t;
+typedef unsigned long int u_quad_t;
+#elif defined __GLIBC_HAVE_LONG_LONG
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+#endif
+typedef u_quad_t fsid_t;
# define __u_char_defined
#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
+#if !defined(__daddr_t_defined) && defined(linux)
+typedef long int daddr_t;
+typedef char *caddr_t;
# define __daddr_t_defined
#endif
--- a/libc/sunrpc/rpc_main.c
+++ b/libc/sunrpc/rpc_main.c
@@ -996,9 +996,10 @@ mkfile_output (struct commandline *cmd)
abort ();
temp = rindex (cmd->infile, '.');
cp = stpcpy (mkfilename, "Makefile.");
- if (temp != NULL)
- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
- else
+ if (temp != NULL) {
+ strncpy(cp, cmd->infile, temp - cmd->infile);
+ cp[temp - cmd->infile - 1] = 0;
+ } else
stpcpy (cp, cmd->infile);
}

View File

@ -0,0 +1,27 @@
--- a/libc/timezone/zic.c
+++ b/libc/timezone/zic.c
@@ -8,6 +8,8 @@ static char elsieid[] = "@(#)zic.c 8.19"
#ifdef CROSS_ZIC
#define REPORT_BUGS_TO ""
#define PKGVERSION ""
+#undef _
+#define _(X) (X)
#else
#include "config.h"
#endif
@@ -490,6 +492,7 @@ char * argv[];
#ifdef unix
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif /* defined unix */
+#ifndef CROSS_ZIC
#if HAVE_GETTEXT
(void) setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
@@ -497,6 +500,7 @@ char * argv[];
#endif /* defined TEXTDOMAINDIR */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
+#endif
progname = argv[0];
if (TYPE_BIT(zic_t) < 64) {
(void) fprintf(stderr, "%s: %s\n", progname,

View File

@ -0,0 +1,71 @@
--- a/libc/sunrpc/proto.h
+++ b/libc/sunrpc/proto.h
@@ -56,12 +56,14 @@ void add_type(int len, const char *type)
$build's C library and $host's GLIBC. */
#ifdef _CROSS_RPCGEN_
+#undef stpcpy
+
/* Rather then defining _GNU_SOURCE before including $build's <string.h>
we just declare stpcpy here. */
extern char *stpcpy (char *, const char *);
-/* Use $build's i18n support as we can't use $host's. */
-#define _(X) (gettext (X))
+/* Do not use i18n support */
+#define _(X) (X)
/* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
that rpcgen generates. The proper fix would be to rename all those checks
--- a/libc/sunrpc/rpc/types.h
+++ b/libc/sunrpc/rpc/types.h
@@ -70,18 +70,23 @@ typedef unsigned long rpcport_t;
#endif
#ifndef __u_char_defined
-typedef __u_char u_char;
-typedef __u_short u_short;
-typedef __u_int u_int;
-typedef __u_long u_long;
-typedef __quad_t quad_t;
-typedef __u_quad_t u_quad_t;
-typedef __fsid_t fsid_t;
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+#if __WORDSIZE == 64
+typedef long int quad_t;
+typedef unsigned long int u_quad_t;
+#elif defined __GLIBC_HAVE_LONG_LONG
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+#endif
+typedef u_quad_t fsid_t;
# define __u_char_defined
#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
+#if !defined(__daddr_t_defined) && defined(linux)
+typedef long int daddr_t;
+typedef char *caddr_t;
# define __daddr_t_defined
#endif
--- a/libc/sunrpc/rpc_main.c
+++ b/libc/sunrpc/rpc_main.c
@@ -997,9 +997,10 @@ mkfile_output (struct commandline *cmd)
abort ();
temp = rindex (cmd->infile, '.');
cp = stpcpy (mkfilename, "Makefile.");
- if (temp != NULL)
- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
- else
+ if (temp != NULL) {
+ strncpy(cp, cmd->infile, temp - cmd->infile);
+ cp[temp - cmd->infile - 1] = 0;
+ } else
stpcpy (cp, cmd->infile);
}

View File

@ -0,0 +1,27 @@
--- a/libc/timezone/zic.c
+++ b/libc/timezone/zic.c
@@ -8,6 +8,8 @@ static char elsieid[] = "@(#)zic.c 8.19"
#ifdef CROSS_ZIC
#define REPORT_BUGS_TO ""
#define PKGVERSION ""
+#undef _
+#define _(X) (X)
#else
#include "config.h"
#endif
@@ -490,6 +492,7 @@ char * argv[];
#ifdef unix
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif /* defined unix */
+#ifndef CROSS_ZIC
#if HAVE_GETTEXT
(void) setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
@@ -497,6 +500,7 @@ char * argv[];
#endif /* defined TEXTDOMAINDIR */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
+#endif
progname = argv[0];
if (TYPE_BIT(zic_t) < 64) {
(void) fprintf(stderr, "%s: %s\n", progname,