]> code.ossystems Code Review - openembedded-core.git/blob
03b0ce77edaa4e5452f38fbee7c328b63457c5a6
[openembedded-core.git] /
1 From d4fd6975671477721936060771aa4d7d07fb0910 Mon Sep 17 00:00:00 2001
2 From: Werner Koch <wk@gnupg.org>
3 Date: Tue, 18 Sep 2018 14:54:08 +0200
4 Subject: [PATCH libgpg-error] syscfg: Support ARC CPUs and simplify aliasing
5  table.
6
7 * src/mkheader.c (xmalloc): New.
8 (xstrdup): Implement using xmalloc.
9 (canon_host_triplet): Add supporr for arc CPU.  Adjust alias table to
10 also alias *-pc-*.  Rename ibm to unknown. Add internal arg.  Add
11 unknown vendor hack.
12 (main): New mode to just print the canonicalized form.
13 * src/Makefile.am (lock_obj_pub): s/-(pc|ibm)-/-unknown/.  Also rename
14 files accordingly.
15 --
16
17 config.sub does no real aliasing and thus we would need to add several
18 vendors to the alising tables despite that this has no technical
19 meanding.  Instead we now replace the vendor with "unknown" for the
20 4-part-"triplets".  This change will make maintenace easier.
21
22 Signed-off-by: Werner Koch <wk@gnupg.org>
23
24 Upstream-Status: Backport [ http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=commit;h=48c8f8ddfc80 ]
25 ---
26  src/Makefile.am                               | 16 ++--
27  src/mkheader.c                                | 92 ++++++++++++++++---
28  ...-gnu.h => lock-obj-pub.i686-unknown-gnu.h} |  0
29  ... lock-obj-pub.i686-unknown-kfreebsd-gnu.h} |  0
30  ... => lock-obj-pub.i686-unknown-linux-gnu.h} |  0
31  ...=> lock-obj-pub.s390x-unknown-linux-gnu.h} |  0
32  ...ock-obj-pub.x86_64-unknown-kfreebsd-gnu.h} |  0
33  ...> lock-obj-pub.x86_64-unknown-linux-gnu.h} |  0
34  ...ock-obj-pub.x86_64-unknown-linux-gnux32.h} |  0
35  ... lock-obj-pub.x86_64-unknown-linux-musl.h} |  0
36  10 files changed, 85 insertions(+), 23 deletions(-)
37  rename src/syscfg/{lock-obj-pub.i686-pc-gnu.h => lock-obj-pub.i686-unknown-gnu.h} (100%)
38  rename src/syscfg/{lock-obj-pub.i686-pc-kfreebsd-gnu.h => lock-obj-pub.i686-unknown-kfreebsd-gnu.h} (100%)
39  rename src/syscfg/{lock-obj-pub.i686-pc-linux-gnu.h => lock-obj-pub.i686-unknown-linux-gnu.h} (100%)
40  rename src/syscfg/{lock-obj-pub.s390x-ibm-linux-gnu.h => lock-obj-pub.s390x-unknown-linux-gnu.h} (100%)
41  rename src/syscfg/{lock-obj-pub.x86_64-pc-kfreebsd-gnu.h => lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h} (100%)
42  rename src/syscfg/{lock-obj-pub.x86_64-pc-linux-gnu.h => lock-obj-pub.x86_64-unknown-linux-gnu.h} (100%)
43  rename src/syscfg/{lock-obj-pub.x86_64-pc-linux-gnux32.h => lock-obj-pub.x86_64-unknown-linux-gnux32.h} (100%)
44  rename src/syscfg/{lock-obj-pub.x86_64-pc-linux-musl.h => lock-obj-pub.x86_64-unknown-linux-musl.h} (100%)
45
46 diff --git a/src/Makefile.am b/src/Makefile.am
47 index 42998e46a3bc..8ec582ef99fb 100644
48 --- a/src/Makefile.am
49 +++ b/src/Makefile.am
50 @@ -52,9 +52,9 @@ lock_obj_pub = \
51         syscfg/lock-obj-pub.arm-apple-darwin.h              \
52          syscfg/lock-obj-pub.hppa-unknown-linux-gnu.h        \
53         syscfg/lock-obj-pub.i386-apple-darwin.h             \
54 -        syscfg/lock-obj-pub.i686-pc-gnu.h                   \
55 -        syscfg/lock-obj-pub.i686-pc-kfreebsd-gnu.h          \
56 -        syscfg/lock-obj-pub.i686-pc-linux-gnu.h             \
57 +        syscfg/lock-obj-pub.i686-unknown-gnu.h              \
58 +        syscfg/lock-obj-pub.i686-unknown-kfreebsd-gnu.h     \
59 +        syscfg/lock-obj-pub.i686-unknown-linux-gnu.h        \
60          syscfg/lock-obj-pub.m68k-unknown-linux-gnu.h        \
61          syscfg/lock-obj-pub.mips-unknown-linux-gnu.h        \
62          syscfg/lock-obj-pub.mips64el-unknown-linux-gnuabi64.h \
63 @@ -66,16 +66,16 @@ lock_obj_pub = \
64         syscfg/lock-obj-pub.powerpc64le-unknown-linux-gnu.h \
65         syscfg/lock-obj-pub.powerpc-unknown-linux-gnuspe.h  \
66         syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h     \
67 -        syscfg/lock-obj-pub.s390x-ibm-linux-gnu.h           \
68 +        syscfg/lock-obj-pub.s390x-unknown-linux-gnu.h       \
69          syscfg/lock-obj-pub.sh3-unknown-linux-gnu.h         \
70          syscfg/lock-obj-pub.sh4-unknown-linux-gnu.h         \
71          syscfg/lock-obj-pub.sparc-unknown-linux-gnu.h       \
72          syscfg/lock-obj-pub.sparc64-unknown-linux-gnu.h     \
73         syscfg/lock-obj-pub.x86_64-apple-darwin.h           \
74 -        syscfg/lock-obj-pub.x86_64-pc-kfreebsd-gnu.h        \
75 -        syscfg/lock-obj-pub.x86_64-pc-linux-gnu.h           \
76 -        syscfg/lock-obj-pub.x86_64-pc-linux-gnux32.h        \
77 -        syscfg/lock-obj-pub.x86_64-pc-linux-musl.h          \
78 +        syscfg/lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h   \
79 +        syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h      \
80 +        syscfg/lock-obj-pub.x86_64-unknown-linux-gnux32.h   \
81 +        syscfg/lock-obj-pub.x86_64-unknown-linux-musl.h     \
82         syscfg/lock-obj-pub.tilegx-unknown-linux-gnu.h      \
83         syscfg/lock-obj-pub.ia64-unknown-linux-gnu.h        \
84         syscfg/lock-obj-pub.mingw32.h
85 diff --git a/src/mkheader.c b/src/mkheader.c
86 index 2fc5fada66a4..7a38a1bec1a4 100644
87 --- a/src/mkheader.c
88 +++ b/src/mkheader.c
89 @@ -51,17 +51,27 @@ xfree (void *a)
90  
91  
92  static char *
93 -xstrdup (const char *string)
94 +xmalloc (size_t n)
95  {
96    char *p;
97 -  size_t len = strlen (string) + 1;
98  
99 -  p = malloc (len);
100 +  p = malloc (n);
101    if (!p)
102      {
103        fputs (PGM ": out of core\n", stderr);
104        exit (1);
105      }
106 +  return p;
107 +}
108 +
109 +
110 +static char *
111 +xstrdup (const char *string)
112 +{
113 +  char *p;
114 +  size_t len = strlen (string) + 1;
115 +
116 +  p = xmalloc (len);
117    memcpy (p, string, len);
118    return p;
119  }
120 @@ -69,23 +79,31 @@ xstrdup (const char *string)
121  
122  /* Return a malloced string with TRIPLET.  If TRIPLET has an alias
123     return that instead.  In general build-aux/config.sub should do the
124 -   aliasing but some returned triplets are anyway identical and thus we
125 -   use this function to map it to the canonical form.  */
126 +   aliasing but some returned triplets are anyway identical and thus
127 +   we use this function to map it to the canonical form.
128 +   NO_VENDOR_HACK is for internal use; caller must call with 0. */
129  static char *
130 -canon_host_triplet (const char *triplet)
131 +canon_host_triplet (const char *triplet, int no_vendor_hack)
132  {
133    struct {
134      const char *name;
135      const char *alias;
136    } tbl[] = {
137 -    {"i486-pc-linux-gnu", "i686-pc-linux-gnu" },
138 +    {"i486-pc-linux-gnu", "i686-unknown-linux-gnu" },
139      {"i586-pc-linux-gnu" },
140 -    {"i486-pc-gnu", "i686-pc-gnu"},
141 +    {"i686-pc-linux-gnu" },
142 +    {"arc-oe-linux-uclibc" }, /* Other CPU but same struct.  */
143 +
144 +    {"i486-pc-gnu", "i686-unknown-gnu"},
145      {"i586-pc-gnu"},
146 -    {"i486-pc-kfreebsd-gnu", "i686-pc-kfreebsd-gnu"},
147 +    {"i686-pc-gnu"},
148 +
149 +    {"i486-pc-kfreebsd-gnu", "i686-unknown-kfreebsd-gnu"},
150      {"i586-pc-kfreebsd-gnu"},
151 +    {"i686-pc-kfreebsd-gnu"},
152  
153 -    {"x86_64-pc-linux-gnuhardened1", "x86_64-pc-linux-gnu" },
154 +    {"x86_64-pc-linux-gnuhardened1", "x86_64-unknown-linux-gnu" },
155 +    {"x86_64-pc-linux-gnu" },
156  
157      {"powerpc-unknown-linux-gnuspe", "powerpc-unknown-linux-gnu" },
158  
159 @@ -98,6 +116,7 @@ canon_host_triplet (const char *triplet)
160    };
161    int i;
162    const char *lastalias = NULL;
163 +  const char *s;
164  
165    for (i=0; tbl[i].name; i++)
166      {
167 @@ -110,6 +129,36 @@ canon_host_triplet (const char *triplet)
168            return xstrdup (lastalias);
169          }
170      }
171 +  for (i=0, s=triplet; *s; s++)
172 +    if (*s == '-')
173 +      i++;
174 +  if (i > 2 && !no_vendor_hack)
175 +    {
176 +      /* We have a 4 part "triplet": CPU-VENDOR-KERNEL-SYSTEM where
177 +       * the last two parts replace the OS part of a real triplet.
178 +       * The VENDOR part is then in general useless because
179 +       * KERNEL-SYSTEM is specific enough.  We now do a second pass by
180 +       * replacing VENDOR with "unknown".  */
181 +      char *p;
182 +      char *buf = xmalloc (strlen (triplet) + 7 + 1);
183 +
184 +      for (p=buf,s=triplet,i=0; *s; s++)
185 +        {
186 +          *p++ = *s;
187 +          if (*s == '-' && ++i == 1)
188 +            {
189 +              memcpy (p, "unknown-",8);
190 +              p += 8;
191 +              for (s++; *s != '-'; s++)
192 +                ;
193 +            }
194 +        }
195 +      *p = 0;
196 +      p = canon_host_triplet (buf, 1);
197 +      xfree (buf);
198 +      return p;
199 +    }
200 +
201    return xstrdup (triplet);
202  }
203  
204 @@ -558,7 +607,7 @@ write_special (const char *fname, int lnr, const char *tag)
205  int
206  main (int argc, char **argv)
207  {
208 -  FILE *fp;
209 +  FILE *fp = NULL;
210    char line[LINESIZE];
211    int lnr = 0;
212    const char *fname, *s;
213 @@ -571,11 +620,22 @@ main (int argc, char **argv)
214        argc--; argv++;
215      }
216  
217 -  if (argc != 6)
218 +  if (argc == 1)
219 +    {
220 +      /* Print just the canonicalized host triplet.  */
221 +      host_triplet = canon_host_triplet (argv[0], 0);
222 +      printf ("%s\n", host_triplet);
223 +      goto leave;
224 +    }
225 +  else if (argc == 6)
226 +    ; /* Standard operation.  */
227 +  else
228      {
229        fputs ("usage: " PGM
230               " host_os host_triplet template.h config.h"
231 -             " version version_number\n",
232 +             " version version_number\n"
233 +             "       " PGM
234 +             " host_triplet\n",
235               stderr);
236        return 1;
237      }
238 @@ -586,7 +646,7 @@ main (int argc, char **argv)
239    hdr_version = argv[4];
240    hdr_version_number = argv[5];
241  
242 -  host_triplet = canon_host_triplet (host_triplet_raw);
243 +  host_triplet = canon_host_triplet (host_triplet_raw, 0);
244  
245    srcdir = malloc (strlen (fname) + 2 + 1);
246    if (!srcdir)
247 @@ -677,13 +737,15 @@ main (int argc, char **argv)
248           "End:\n"
249           "*/\n", stdout);
250  
251 + leave:
252    if (ferror (stdout))
253      {
254        fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno));
255        return 1;
256      }
257  
258 -  fclose (fp);
259 +  if (fp)
260 +    fclose (fp);
261  
262    xfree (host_triplet);
263    return 0;
264 diff --git a/src/syscfg/lock-obj-pub.i686-pc-gnu.h b/src/syscfg/lock-obj-pub.i686-unknown-gnu.h
265 similarity index 100%
266 rename from src/syscfg/lock-obj-pub.i686-pc-gnu.h
267 rename to src/syscfg/lock-obj-pub.i686-unknown-gnu.h
268 diff --git a/src/syscfg/lock-obj-pub.i686-pc-kfreebsd-gnu.h b/src/syscfg/lock-obj-pub.i686-unknown-kfreebsd-gnu.h
269 similarity index 100%
270 rename from src/syscfg/lock-obj-pub.i686-pc-kfreebsd-gnu.h
271 rename to src/syscfg/lock-obj-pub.i686-unknown-kfreebsd-gnu.h
272 diff --git a/src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h b/src/syscfg/lock-obj-pub.i686-unknown-linux-gnu.h
273 similarity index 100%
274 rename from src/syscfg/lock-obj-pub.i686-pc-linux-gnu.h
275 rename to src/syscfg/lock-obj-pub.i686-unknown-linux-gnu.h
276 diff --git a/src/syscfg/lock-obj-pub.s390x-ibm-linux-gnu.h b/src/syscfg/lock-obj-pub.s390x-unknown-linux-gnu.h
277 similarity index 100%
278 rename from src/syscfg/lock-obj-pub.s390x-ibm-linux-gnu.h
279 rename to src/syscfg/lock-obj-pub.s390x-unknown-linux-gnu.h
280 diff --git a/src/syscfg/lock-obj-pub.x86_64-pc-kfreebsd-gnu.h b/src/syscfg/lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h
281 similarity index 100%
282 rename from src/syscfg/lock-obj-pub.x86_64-pc-kfreebsd-gnu.h
283 rename to src/syscfg/lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h
284 diff --git a/src/syscfg/lock-obj-pub.x86_64-pc-linux-gnu.h b/src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h
285 similarity index 100%
286 rename from src/syscfg/lock-obj-pub.x86_64-pc-linux-gnu.h
287 rename to src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h
288 diff --git a/src/syscfg/lock-obj-pub.x86_64-pc-linux-gnux32.h b/src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnux32.h
289 similarity index 100%
290 rename from src/syscfg/lock-obj-pub.x86_64-pc-linux-gnux32.h
291 rename to src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnux32.h
292 diff --git a/src/syscfg/lock-obj-pub.x86_64-pc-linux-musl.h b/src/syscfg/lock-obj-pub.x86_64-unknown-linux-musl.h
293 similarity index 100%
294 rename from src/syscfg/lock-obj-pub.x86_64-pc-linux-musl.h
295 rename to src/syscfg/lock-obj-pub.x86_64-unknown-linux-musl.h
296 -- 
297 2.17.1
298