debuggers.hg

view xen/common/libelf/libelf-private.h @ 13699:1b32e279ddef

libelf cannot rely on the strlcpy() BSD-ism.
Make a private definition based on strncpy and strlen.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Jan 29 11:47:00 2007 +0000 (2007-01-29)
parents f8ddcb758117
children bef7fbe25a9f
line source
1 #ifndef __LIBELF_PRIVATE_H__
2 #define __LIBELF_PRIVATE_H_
4 #ifdef __XEN__
6 #include <xen/config.h>
7 #include <xen/types.h>
8 #include <xen/string.h>
9 #include <xen/lib.h>
10 #include <asm/byteorder.h>
11 #include <public/elfnote.h>
12 #include <public/libelf.h>
14 #define elf_msg(elf, fmt, args ... ) \
15 if (elf->verbose) printk(fmt, ## args )
16 #define elf_err(elf, fmt, args ... ) \
17 printk(fmt, ## args )
19 #define strtoull(str, end, base) simple_strtoull(str, end, base)
20 #define bswap_16(x) swab16(x)
21 #define bswap_32(x) swab32(x)
22 #define bswap_64(x) swab64(x)
24 #define elf_strlcpy(d,s,c) strlcpy(d,s,c)
26 #else /* !__XEN__ */
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stddef.h>
32 #include <inttypes.h>
33 #ifdef __sun__
34 #include <sys/byteorder.h>
35 #define bswap_16(x) BSWAP_16(x)
36 #define bswap_32(x) BSWAP_32(x)
37 #define bswap_64(x) BSWAP_64(x)
38 #else
39 #include <byteswap.h>
40 #endif
41 #include <xen/elfnote.h>
42 #include <xen/libelf.h>
44 #include "xenctrl.h"
45 #include "xc_private.h"
47 #define elf_msg(elf, fmt, args ... ) \
48 if (elf->log && elf->verbose) fprintf(elf->log, fmt , ## args )
49 #define elf_err(elf, fmt, args ... ) do { \
50 if (elf->log) \
51 fprintf(elf->log, fmt , ## args ); \
52 xc_set_error(XC_INVALID_KERNEL, fmt , ## args ); \
53 } while (0)
55 /* SysV unices have no strlcpy/strlcat. */
56 static inline size_t elf_strlcpy(char *dest, const char *src, size_t size)
57 {
58 strncpy(dest, src, size-1);
59 dest[size-1] = '\0';
60 return strlen(src);
61 }
63 #endif
65 #endif /* __LIBELF_PRIVATE_H_ */