Ignore machine-check MSRs
[freebsd-src/fkvm-freebsd.git] / libexec / rtld-aout / support.c
blob71a84ffa129985ebcc1b9eed1e8b0bf481adf444
1 /*
2 * Generic "support" routines to replace those obtained from libiberty for ld.
4 * I've collected these from random bits of (published) code I've written
5 * over the years, not that they are a big deal. peter@freebsd.org
6 *-
7 * Copyright (C) 1996
8 * Peter Wemm. All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * $FreeBSD$
33 #include <sys/types.h>
34 #include <string.h>
35 #include <stdlib.h>
36 #include <err.h>
38 #include "support.h"
40 char *
41 concat(s1, s2, s3)
42 const char *s1, *s2, *s3;
44 int len = 1;
45 char *s;
46 if (s1)
47 len += strlen(s1);
48 if (s2)
49 len += strlen(s2);
50 if (s3)
51 len += strlen(s3);
52 s = xmalloc(len);
53 s[0] = '\0';
54 if (s1)
55 strcat(s, s1);
56 if (s2)
57 strcat(s, s2);
58 if (s3)
59 strcat(s, s3);
60 return s;
63 void *
64 xmalloc(n)
65 size_t n;
67 char *p = malloc(n);
69 if (p == NULL)
70 errx(1, "Could not allocate memory");
72 return p;
75 void *
76 xrealloc(p, n)
77 void *p;
78 size_t n;
80 p = realloc(p, n);
82 if (p == NULL)
83 errx(1, "Could not allocate memory");
85 return p;