1 /* 2 * stdinc.h 3 * pull in standard headers (including portability hacks) 4 * 5 * SPDX-License-Identifier: pkgconf 6 * 7 * Copyright (c) 2012 pkgconf authors (see AUTHORS). 8 * 9 * Permission to use, copy, modify, and/or distribute this software for any 10 * purpose with or without fee is hereby granted, provided that the above 11 * copyright notice and this permission notice appear in all copies. 12 * 13 * This software is provided 'as is' and without any warranty, express or 14 * implied. In no event shall the authors be liable for any damages arising 15 * from the use of this software. 16 */ 17 18 #ifndef LIBPKGCONF_STDINC_H 19 #define LIBPKGCONF_STDINC_H 20 21 /* make POSIX/BSD declarations (e.g. strdup) visible even under a strict -std= */ 22 #ifndef _DEFAULT_SOURCE 23 # define _DEFAULT_SOURCE 24 #endif 25 26 #include <ctype.h> 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <stddef.h> 30 #include <stdbool.h> 31 #include <stdarg.h> 32 #include <string.h> 33 #include <sys/types.h> 34 #include <stdint.h> 35 #include <errno.h> 36 37 #ifdef _WIN32 38 # define WIN32_LEAN_AND_MEAN 39 # include <windows.h> 40 # include <malloc.h> 41 # include <io.h> /* for _setmode() */ 42 # include <fcntl.h> 43 # define PATH_DEV_NULL "nul" 44 # ifdef _MSC_VER 45 # if _MSC_VER >= 1900 46 # define SIZE_FMT_SPECIFIER "%zu" 47 # else 48 # ifdef _WIN64 49 # define SIZE_FMT_SPECIFIER "%I64u" 50 # else 51 # define SIZE_FMT_SPECIFIER "%u" 52 # endif 53 # endif 54 # else 55 # ifdef _WIN64 56 # ifndef __MINGW32__ 57 # define SIZE_FMT_SPECIFIER "%I64u" 58 # else 59 # define SIZE_FMT_SPECIFIER "%llu" 60 # endif 61 # else 62 # define SIZE_FMT_SPECIFIER "%u" 63 # endif 64 # endif 65 # ifndef ssize_t 66 # ifndef __MINGW32__ 67 # include <BaseTsd.h> 68 # else 69 # include <basetsd.h> 70 # endif 71 # define ssize_t SSIZE_T 72 # endif 73 # ifndef __MINGW32__ 74 # include "win-dirent.h" 75 # else 76 # include <dirent.h> 77 # endif 78 # define PKGCONF_ITEM_SIZE (_MAX_PATH + 1024) 79 # define PKG_CONFIG_PATH_SEP_S ";" 80 # define PKG_DIR_SEP_S '\\' 81 # define strcasecmp _stricmp 82 # define strncasecmp _strnicmp 83 # define realpath(N,R) _fullpath((R),(N),_MAX_PATH) 84 #else 85 # define PATH_DEV_NULL "/dev/null" 86 # define SIZE_FMT_SPECIFIER "%zu" 87 # ifdef __HAIKU__ 88 # include <FindDirectory.h> 89 # endif 90 # include <dirent.h> 91 # include <unistd.h> 92 # include <limits.h> 93 # include <strings.h> 94 # include <fcntl.h> // open 95 # include <libgen.h> // basename/dirname 96 # include <sys/stat.h> // lstat, S_ISLNK 97 # include <unistd.h> // close, readlinkat 98 # include <string.h> 99 # ifdef PATH_MAX 100 # define PKGCONF_ITEM_SIZE (PATH_MAX + 1024) 101 # else 102 # define PKGCONF_ITEM_SIZE (4096 + 1024) 103 # endif 104 # define PKG_CONFIG_PATH_SEP_S ":" 105 # define PKG_DIR_SEP_S '/' 106 #endif 107 108 #endif 109