From: Davide Beatrici git@davidebeatrici.dev
In order to reduce the amount of duplicates across the codebase. --- include/Makefile.in | 1 + include/wine/dir.h | 69 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 include/wine/dir.h
diff --git a/include/Makefile.in b/include/Makefile.in index 1c04f9a298b..561ad2d1285 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -821,6 +821,7 @@ SOURCES = \ wine/condrv.h \ wine/dcetypes.idl \ wine/debug.h \ + wine/dir.h \ wine/dplaysp.h \ wine/epm.idl \ wine/exception.h \ diff --git a/include/wine/dir.h b/include/wine/dir.h new file mode 100644 index 00000000000..dac9c52a604 --- /dev/null +++ b/include/wine/dir.h @@ -0,0 +1,69 @@ +/* + * Definitions for internal dirs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_WINE_DIR_H +#define __WINE_WINE_DIR_H + +#define SO_DIR_I386 "i386-unix" +#define PE_DIR_I386 "i386-windows" + +#define SO_DIR_X86_64 "x86_64-unix" +#define PE_DIR_X86_64 "x86_64-windows" + +#define SO_DIR_ARM "arm-unix" +#define PE_DIR_ARM "arm-windows" + +#define SO_DIR_AARCH64 "aarch64-unix" +#define PE_DIR_AARCH64 "aarch64-windows" + +#define SO_DIR_MAXLEN (sizeof(SO_DIR_AARCH64) - 1) +#define PE_DIR_MAXLEN (sizeof(PE_DIR_AARCH64) - 1) + +#if defined(__i386__) +#define SO_DIR SO_DIR_I386 +#define PE_DIR PE_DIR_I386 +#elif defined(__x86_64__) +#define SO_DIR SO_DIR_X86_64 +#define PE_DIR PE_DIR_X86_64 +#elif defined(__arm__) +#define SO_DIR SO_DIR_ARM +#define PE_DIR PE_DIR_ARM +#elif defined(__aarch64__) +#define SO_DIR SO_DIR_AARCH64 +#define PE_DIR PE_DIR_AARCH64 +#else +#define SO_DIR "" +#define PE_DIR "" +#endif + +static inline const char *get_pe_dir( const unsigned short machine ) +{ + switch (machine) + { + case 0x0000: return ""; /* IMAGE_FILE_MACHINE_UNKNOWN */ + case 0x0001: return PE_DIR; /* IMAGE_FILE_MACHINE_TARGET_HOST */ + case 0x014c: return PE_DIR_I386; /* IMAGE_FILE_MACHINE_I386 */ + case 0x8664: return PE_DIR_X86_64; /* IMAGE_FILE_MACHINE_AMD64 */ + case 0x01c4: return PE_DIR_ARM; /* IMAGE_FILE_MACHINE_ARMNT */ + case 0xaa64: return PE_DIR_AARCH64; /* IMAGE_FILE_MACHINE_ARM64 */ + } + + return NULL; +} + +#endif /* __WINE_WINE_DIR_H */