diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ChangeLog | 39 | ||||
| -rw-r--r-- | lib/Makefile.am | 50 | ||||
| -rw-r--r-- | lib/eu-config.h | 51 | ||||
| -rw-r--r-- | lib/eu_compat.def.in | 7 | ||||
| -rw-r--r-- | lib/features.h.in | 43 | ||||
| -rw-r--r-- | lib/printversion.h | 10 | ||||
| -rw-r--r-- | lib/system.h | 21 | ||||
| -rw-r--r-- | lib/xstrndup.c | 2 |
8 files changed, 208 insertions, 15 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 1f162286..7cfa768a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,42 @@ +2017-05-04 Ulf Hermann <[email protected]> + + * Makefile.am: On windows, build an eu_compat.dll to forward symbols + from the C and std C++ libraries elfutils links against. + * eu_compat.def.in: New file. + +2017-05-04 Ulf Hermann <[email protected]> + + * printversion.h: Define ARGP_PROGRAM_VERSION_HOOK_DEF and + ARGP_BUG_ADDRESS_DEF to be non-const and drop the asm tricks. + +2017-05-04 Ulf Hermann <[email protected]> + + * system.h: Define FILE_SYSTEM_PREFIX_LEN, ISDIRSEP, DIRSEP, PATHSEP, + and IS_ABSOLUTE_PATH to help with handling file system paths. + +2017-05-04 Ulf Hermann <[email protected]> + + * eu-config.h: Define O_BINARY to 0 if it doesn't exist. + +2017-05-04 Ulf Hermann <[email protected]> + + * eu-config.h: Define unlocked I/O functions to locked ones if they + are unavailable. + +2017-04-27 Ulf Hermann <[email protected]> + + * eu-config.h: Define attribute_hidden to be empty if the compiler + doesn't support it. + +2017-04-27 Ulf Hermann <[email protected]> + + * Makefile.am: Use fpic_CFLAGS. + +2017-04-27 Ulf Hermann <[email protected]> + + * system.h: Drop mempcpy replacement. + * xstrndup.c: Don't include system.h. + 2017-07-18 Mark Wielaard <[email protected]> * bpf.h: New file. diff --git a/lib/Makefile.am b/lib/Makefile.am index ada2030d..7caafa3e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -28,7 +28,7 @@ ## not, see <http://www.gnu.org/licenses/>. ## include $(top_srcdir)/config/eu.am -AM_CFLAGS += -fPIC +AM_CFLAGS += $(fpic_CFLAGS) AM_CPPFLAGS += -I$(srcdir)/../libelf noinst_LIBRARIES = libeu.a @@ -39,8 +39,54 @@ libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \ noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \ md5.h sha1.h eu-config.h color.h printversion.h bpf.h -EXTRA_DIST = dynamicsizehash.c +EXTRA_DIST = dynamicsizehash.c features.h.in if !GPROF xmalloc_CFLAGS = -ffunction-sections endif + +if SELFCONTAINED +install-headers: install-am features.h.in + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_HEADER) $(top_srcdir)/lib/features.h.in $(DESTDIR)$(includedir)/features.h + +uninstall-headers: uninstall-am + rm -f $(DESTDIR)$(includedir)/features.h +else +install-headers: +uninstall-headers: +endif + +EXTRA_DIST += eu_compat.def.in +if NATIVE_PE +eu_compat.def: eu_compat.def.in + cp $< $@ + +$(libeu_compat_BARE): eu_compat.def + $(CCLD) $(dso_LDFLAGS) $(LDFLAGS) -o $@ $< -lstdc++ + +noinst_DATA = $(eu_compat_BARE) + +install-lib: $(libeu_compat_BARE) $(libeu_compat_BARE:.dll=.lib) + $(mkinstalldirs) $(DESTDIR)$(libdir) + $(INSTALL_PROGRAM) $(libeu_compat_BARE) $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED) + ln -fs $(libeu_compat_VERSIONED) $(DESTDIR)$(libdir)/$(libeu_compat_SONAME) + ln -fs $(libeu_compat_SONAME) $(DESTDIR)$(libdir)/$(libeu_compat_BARE) + $(INSTALL_PROGRAM) $(libeu_compat_BARE:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED:.dll=.lib) + ln -fs $(libeu_compat_VERSIONED:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_SONAME:.dll=.lib) + ln -fs $(libeu_compat_SONAME:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_BARE:.dll=.lib) +uninstall-lib: + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED) + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_SONAME) + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_BARE) + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED:.dll=.lib) + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_SONAME:.dll=.lib) + rm -f $(DESTDIR)$(libdir)/$(libeu_compat_BARE:.dll=.lib) +CLEANFILES += $(libeu_compat_BARE:.dll=.lib) $(libeu_compat_BARE:.dll=.exp) +else +install-lib: +uninstall-lib: +endif + +install: install-am install-headers install-lib +uninstall: uninstall-am uninstall-headers install-lib diff --git a/lib/eu-config.h b/lib/eu-config.h index 400cdc6e..f2d91753 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -68,8 +68,20 @@ #define internal_strong_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function; +#ifdef HAVE_VISIBILITY #define attribute_hidden \ __attribute__ ((visibility ("hidden"))) +#else +#define attribute_hidden /* empty */ +#endif + +#ifdef HAVE_GCC_STRUCT +#define attribute_packed \ + __attribute__ ((packed, gcc_struct)) +#else +#define attribute_packed \ + __attribute__ ((packed)) +#endif /* Define ALLOW_UNALIGNED if the architecture allows operations on unaligned memory locations. */ @@ -186,5 +198,44 @@ asm (".section predict_data, \"aw\"; .previous\n" # define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING" #endif +#if !HAVE_FLOCKFILE +# define flockfile(fp) /* nop */ +#endif + +#if !HAVE_FUNLOCKFILE +# define funlockfile(fp) /* nop */ +#endif + +#if !HAVE_DECL_FEOF_UNLOCKED +#define feof_unlocked(x) feof (x) +#endif + +#if !HAVE_DECL_FERROR_UNLOCKED +#define ferror_unlocked(x) ferror (x) +#endif + +#if !HAVE_DECL_FPUTC_UNLOCKED +#define fputc_unlocked(x,y) fputc (x,y) +#endif + +#if !HAVE_DECL_FPUTS_UNLOCKED +#define fputs_unlocked(x,y) fputs (x,y) +#endif + +#if !HAVE_DECL_FWRITE_UNLOCKED +#define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) +#endif + +#if !HAVE_DECL_PUTC_UNLOCKED +#define putc_unlocked(x,y) putc (x,y) +#endif + +#if !HAVE_DECL_PUTCHAR_UNLOCKED +#define putchar_unlocked(x) putchar (x) +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif #endif /* eu-config.h */ diff --git a/lib/eu_compat.def.in b/lib/eu_compat.def.in new file mode 100644 index 00000000..c2aa88ff --- /dev/null +++ b/lib/eu_compat.def.in @@ -0,0 +1,7 @@ +LIBRARY "eu_compat.dll" +EXPORTS +eu_compat_demangle=__cxa_demangle +eu_compat_open=msvcrt._open +eu_compat_close=msvcrt._close +eu_compat_malloc=msvcrt.malloc +eu_compat_free=msvcrt.free diff --git a/lib/features.h.in b/lib/features.h.in new file mode 100644 index 00000000..6eb3c67d --- /dev/null +++ b/lib/features.h.in @@ -0,0 +1,43 @@ +/* This file defines uid_t, gid_t, mode_t, pid_t + Copyright (C) 2017 The Qt Company Ltd + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _FEATURES_H +#define _FEATURES_H 1 + +#include <stdint.h> + +typedef uint32_t uid_t; +typedef uint32_t gid_t; +typedef uint32_t mode_t; +#ifdef _WIN64 +typedef int64_t pid_t; +#else +typedef int32_t pid_t; +#endif + +#endif /* features.h */ diff --git a/lib/printversion.h b/lib/printversion.h index a9e059ff..090b53ab 100644 --- a/lib/printversion.h +++ b/lib/printversion.h @@ -36,14 +36,10 @@ void print_version (FILE *stream, struct argp_state *state); /* We need define two variables, argp_program_version_hook and - argp_program_bug_address, in all programs. argp.h declares these - variables as non-const (which is correct in general). But we can - do better, it is not going to change. So we want to move them into - the .rodata section. Define macros to do the trick. */ + argp_program_bug_address, in all programs. */ #define ARGP_PROGRAM_VERSION_HOOK_DEF \ - void (*const apvh) (FILE *, struct argp_state *) \ - __asm ("argp_program_version_hook") + void (*argp_program_version_hook) (FILE *, struct argp_state *) #define ARGP_PROGRAM_BUG_ADDRESS_DEF \ - const char *const apba__ __asm ("argp_program_bug_address") + const char *argp_program_bug_address #endif // PRINTVERSION_H diff --git a/lib/system.h b/lib/system.h index 92033355..3a6b8e93 100644 --- a/lib/system.h +++ b/lib/system.h @@ -51,6 +51,22 @@ # error "Unknown byte order" #endif +#if (defined _WIN32 || defined __WIN32__) +# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' <= 'z' - 'a') +# define FILE_SYSTEM_PREFIX_LEN(filename) \ + (_IS_DRIVE_LETTER ((filename)[0]) && (filename)[1] == ':' ? 2 : 0) +# define ISDIRSEP(c) ((c) == '/' || (c) == '\\') +# define DIRSEP '\\' +# define PATHSEP ';' +# define IS_ABSOLUTE_PATH(f) ISDIRSEP ((f)[FILE_SYSTEM_PREFIX_LEN (f)]) +#else +# define FILE_SYSTEM_PREFIX_LEN(filename) 0 +# define ISDIRSEP(c) ((c) == '/') +# define DIRSEP '/' +# define PATHSEP ':' +# define IS_ABSOLUTE_PATH(p) (ISDIRSEP ((p)[0])) +#endif + #ifndef MAX #define MAX(m, n) ((m) < (n) ? (n) : (m)) #endif @@ -63,11 +79,6 @@ #define powerof2(x) (((x) & ((x) - 1)) == 0) #endif -#if !HAVE_DECL_MEMPCPY -#define mempcpy(dest, src, n) \ - ((void *) ((char *) memcpy (dest, src, n) + (size_t) n)) -#endif - /* A special gettext function we use if the strings are too short. */ #define sgettext(Str) \ ({ const char *__res = strrchr (gettext (Str), '|'); \ diff --git a/lib/xstrndup.c b/lib/xstrndup.c index a257aa9a..d43e3b9e 100644 --- a/lib/xstrndup.c +++ b/lib/xstrndup.c @@ -33,7 +33,7 @@ #include <stdint.h> #include <string.h> #include "libeu.h" -#include "system.h" + /* Return a newly allocated copy of STRING. */ char * |
