Home | History | Annotate | Download | only in elfutils
      1 #ifndef CONFIG_COMPAT_DARWIN_H
      2 #define CONFIG_COMPAT_DARWIN_H
      3 
      4 #define gettext
      5 #define _gettext
      6 #define _dgettext
      7 
      8 typedef unsigned long long __off64_t;
      9 
     10 #define __LITTLE_ENDIAN (1234)
     11 #define __BIG_ENDIAN    (4321)
     12 #define __BYTE_ORDER    __LITTLE_ENDIAN
     13 
     14 #include <stddef.h>
     15 #include <locale.h> //LC_MESSAGES
     16 #include <assert.h>
     17 #include <stdlib.h>
     18 #include <stdarg.h>
     19 #include <string.h>
     20 #include <errno.h>
     21 #include <stdio.h>
     22 
     23 #define dgettext(domainname, msgid)  dcgettext (domainname, msgid, LC_MESSAGES)
     24 
     25 static inline void __attribute__((noreturn)) error(int status, int errnum, const char *fmt, ...)
     26 {
     27 	va_list lst;
     28 	va_start(lst, fmt);
     29 	vfprintf(stderr, fmt, lst);
     30 	fprintf(stderr, "error %d: %s\n", errnum, strerror(errno));
     31 	va_end(lst);
     32 	exit(status);
     33 }
     34 
     35 static inline char *dcgettext (char *__domainname, char *__msgid, int __category)
     36 {
     37 	error(EXIT_FAILURE, 0, "%s not implemented!", __FUNCTION__);
     38 	return NULL;
     39 }
     40 
     41 static inline size_t strnlen (const char *__string, size_t __maxlen)
     42 {
     43 	int len = 0;
     44 	while (__maxlen-- && *__string++)
     45 		len++;
     46 	return len;
     47 }
     48 
     49 static inline void *mempcpy (void * __dest, const void * __src, size_t __n)
     50 {
     51 	memcpy(__dest, __src, __n);
     52 	return ((char *)__dest) + __n;
     53 }
     54 
     55 #define __mempcpy mempcpy
     56 
     57 static inline wchar_t *wmempcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, size_t __n)
     58 {
     59 	error(EXIT_FAILURE, 0, "%s not implemented!", __FUNCTION__);
     60 	return NULL;
     61 }
     62 
     63 
     64 static inline unsigned short bswap_16(unsigned short val)
     65 {
     66 	return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
     67 }
     68 
     69 static inline unsigned long bswap_32(unsigned long val)
     70 {
     71 	return bswap_16((unsigned short)val) << 16 |
     72                bswap_16((unsigned short)(val >> 16));
     73 }
     74 
     75 static inline unsigned long long bswap_64(unsigned long long val)
     76 {
     77 	return ((((unsigned long long)bswap_32(val)) << 32) |
     78                 (((unsigned long long)bswap_32(val >> 32)) & 0xffffffffULL));
     79 }
     80 
     81 extern int ___libelf_fill_byte;
     82 
     83 #endif /*CONFIG_COMPAT_DARWIN_H*/
     84