From 14a395345aaa9dce84bf178a86243388c1c9f497 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 19 Mar 2023 20:59:17 -0700 Subject: [PATCH] Consistently use _WIN32 instead of __WIN32__ _WIN32 works with all compilers, while __WIN32__ is MinGW-specific. This project used __WIN32__ in files that only support MinGW, and _WIN32 in other files such as the library header and example programs. One place even used WIN32. Avoid this unnecessary complication by just always using _WIN32. --- include/wimlib/apply.h | 2 +- include/wimlib/blob_table.h | 8 ++++---- include/wimlib/compiler.h | 4 ++-- include/wimlib/file_io.h | 2 +- include/wimlib/glob.h | 4 ++-- include/wimlib/paths.h | 2 +- include/wimlib/progress.h | 8 ++++---- include/wimlib/reparse.h | 2 +- include/wimlib/scan.h | 2 +- include/wimlib/util.h | 2 +- include/wimlib/win32.h | 4 ++-- include/wimlib/wof.h | 4 ++-- include/wimlib_tchar.h | 6 +++--- programs/imagex-win32.c | 2 +- programs/imagex.c | 30 +++++++++++++++--------------- src/blob_table.c | 6 +++--- src/dentry.c | 2 +- src/error.c | 4 ++-- src/extract.c | 20 ++++++++++---------- src/file_io.c | 2 +- src/mount_image.c | 4 ++-- src/reparse.c | 4 ++-- src/resource.c | 2 +- src/solid.c | 2 +- src/test_support.c | 16 ++++++++-------- src/timestamp.c | 4 ++-- src/unix_capture.c | 4 ++-- src/update_image.c | 2 +- src/util.c | 14 +++++++------- src/wim.c | 4 ++-- src/wimboot.c | 4 ++-- src/win32_apply.c | 4 ++-- src/win32_capture.c | 4 ++-- src/win32_common.c | 4 ++-- src/win32_replacements.c | 4 ++-- src/win32_vss.c | 4 ++-- src/write.c | 2 +- tests/wlfuzz.c | 28 ++++++++++++++-------------- 38 files changed, 113 insertions(+), 113 deletions(-) diff --git a/include/wimlib/apply.h b/include/wimlib/apply.h index 7813aee1..b290693e 100644 --- a/include/wimlib/apply.h +++ b/include/wimlib/apply.h @@ -268,7 +268,7 @@ struct apply_operations { bool single_tree_only; }; -#ifdef __WIN32__ +#ifdef _WIN32 extern const struct apply_operations win32_apply_ops; #else extern const struct apply_operations unix_apply_ops; diff --git a/include/wimlib/blob_table.h b/include/wimlib/blob_table.h index 952b6dd0..9bb54b54 100644 --- a/include/wimlib/blob_table.h +++ b/include/wimlib/blob_table.h @@ -40,7 +40,7 @@ enum blob_location { BLOB_IN_NTFS_VOLUME, #endif -#ifdef __WIN32__ +#ifdef _WIN32 /* Windows only: the blob's data is available in the file (or named data * stream) specified by @windows_file. The data might be only properly * accessible through the Windows API. */ @@ -384,13 +384,13 @@ static inline bool blob_is_in_file(const struct blob_descriptor *blob) { return blob->blob_location == BLOB_IN_FILE_ON_DISK -#ifdef __WIN32__ +#ifdef _WIN32 || blob->blob_location == BLOB_IN_WINDOWS_FILE #endif ; } -#ifdef __WIN32__ +#ifdef _WIN32 extern const wchar_t * get_windows_file_path(const struct windows_file *file); #endif @@ -398,7 +398,7 @@ get_windows_file_path(const struct windows_file *file); static inline const tchar * blob_file_path(const struct blob_descriptor *blob) { -#ifdef __WIN32__ +#ifdef _WIN32 if (blob->blob_location == BLOB_IN_WINDOWS_FILE) return get_windows_file_path(blob->windows_file); #endif diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 742f3bfc..283152bd 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -51,7 +51,7 @@ /* Declare that the annotated function should be exported from the shared * library (or DLL). */ -#ifdef __WIN32__ +#ifdef _WIN32 # define WIMLIBAPI __declspec(dllexport) #else # define WIMLIBAPI __attribute__((visibility("default"))) @@ -102,7 +102,7 @@ /* Hint that the annotated function takes a printf()-like format string and * arguments. This is currently disabled on Windows because MinGW does not * support this attribute on functions taking wide-character strings. */ -#ifdef __WIN32__ +#ifdef _WIN32 # define _format_attribute(type, format_str, format_start) #else # define _format_attribute(type, format_str, format_start) \ diff --git a/include/wimlib/file_io.h b/include/wimlib/file_io.h index 61ae78b9..7cfe2cd8 100644 --- a/include/wimlib/file_io.h +++ b/include/wimlib/file_io.h @@ -26,7 +26,7 @@ full_write(struct filedes *fd, const void *buf, size_t n); extern int full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset); -#ifndef __WIN32__ +#ifndef _WIN32 # define O_BINARY 0 #endif diff --git a/include/wimlib/glob.h b/include/wimlib/glob.h index 1027ec7c..5455be26 100644 --- a/include/wimlib/glob.h +++ b/include/wimlib/glob.h @@ -1,7 +1,7 @@ #ifndef _WIMLIB_GLOB_H #define _WIMLIB_GLOB_H -#ifndef __WIN32__ +#ifndef _WIN32 # include #else #include @@ -29,6 +29,6 @@ extern void globfree(glob_t *pglob); #define GLOB_ABORTED 2 /* Read error. */ #define GLOB_NOMATCH 3 /* No matches found. */ -#endif /* __WIN32__ */ +#endif /* _WIN32 */ #endif /* _WIMLIB_GLOB_H */ diff --git a/include/wimlib/paths.h b/include/wimlib/paths.h index 6ff7193e..764bdcfb 100644 --- a/include/wimlib/paths.h +++ b/include/wimlib/paths.h @@ -32,7 +32,7 @@ canonicalize_wim_path(const tchar *wim_path); * Currently needs to be '/' on UNIX for the WIM mounting code to work properly. */ -#ifdef __WIN32__ +#ifdef _WIN32 # define OS_PREFERRED_PATH_SEPARATOR L'\\' # define is_any_path_separator(c) ((c) == L'/' || (c) == L'\\') #else diff --git a/include/wimlib/progress.h b/include/wimlib/progress.h index 6d39b7e4..062656c5 100644 --- a/include/wimlib/progress.h +++ b/include/wimlib/progress.h @@ -61,7 +61,7 @@ static inline tchar * progress_get_streamless_path(const tchar *path) { tchar *cookie = NULL; -#ifdef __WIN32__ +#ifdef _WIN32 cookie = (wchar_t *)path_stream_name(path); if (cookie) *--cookie = L'\0'; /* Overwrite the colon */ @@ -74,7 +74,7 @@ progress_get_streamless_path(const tchar *path) static inline tchar * progress_get_win32_path(const tchar *path) { -#ifdef __WIN32__ +#ifdef _WIN32 if (!wcsncmp(path, L"\\??\\", 4)) { ((wchar_t *)path)[1] = L'\\'; return (wchar_t *)&path[1]; @@ -87,7 +87,7 @@ progress_get_win32_path(const tchar *path) static inline void progress_put_win32_path(tchar *cookie) { -#ifdef __WIN32__ +#ifdef _WIN32 if (cookie) *cookie = L'?'; #endif @@ -97,7 +97,7 @@ progress_put_win32_path(tchar *cookie) static inline void progress_put_streamless_path(tchar *cookie) { -#ifdef __WIN32__ +#ifdef _WIN32 if (cookie) *cookie = L':'; #endif diff --git a/include/wimlib/reparse.h b/include/wimlib/reparse.h index dce19a22..04592cec 100644 --- a/include/wimlib/reparse.h +++ b/include/wimlib/reparse.h @@ -98,7 +98,7 @@ extern int make_link_reparse_point(const struct link_reparse_point *link, struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_ret); -#ifndef __WIN32__ +#ifndef _WIN32 extern int wim_inode_readlink(const struct wim_inode *inode, char *buf, size_t bufsize, const struct blob_descriptor *blob, diff --git a/include/wimlib/scan.h b/include/wimlib/scan.h index fbe304e8..bae72c75 100644 --- a/include/wimlib/scan.h +++ b/include/wimlib/scan.h @@ -104,7 +104,7 @@ ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret, const tchar *device, struct scan_params *params); #endif -#ifdef __WIN32__ +#ifdef _WIN32 /* win32_capture.c */ extern int win32_build_dentry_tree(struct wim_dentry **root_ret, diff --git a/include/wimlib/util.h b/include/wimlib/util.h index 350fbbb5..55fc9e4a 100644 --- a/include/wimlib/util.h +++ b/include/wimlib/util.h @@ -57,7 +57,7 @@ wimlib_calloc(size_t nmemb, size_t size); extern char * wimlib_strdup(const char *str); -#ifdef __WIN32__ +#ifdef _WIN32 extern wchar_t * wimlib_wcsdup(const wchar_t *str); #endif diff --git a/include/wimlib/win32.h b/include/wimlib/win32.h index 71a77107..16462096 100644 --- a/include/wimlib/win32.h +++ b/include/wimlib/win32.h @@ -5,7 +5,7 @@ #ifndef _WIMLIB_WIN32_H #define _WIMLIB_WIN32_H -#ifdef __WIN32__ +#ifdef _WIN32 #include "wimlib/types.h" @@ -64,6 +64,6 @@ win32_pread(int fd, void *buf, size_t count, off_t offset); extern ssize_t win32_pwrite(int fd, const void *buf, size_t count, off_t offset); -#endif /* __WIN32__ */ +#endif /* _WIN32 */ #endif /* _WIMLIB_WIN32_H */ diff --git a/include/wimlib/wof.h b/include/wimlib/wof.h index 9d5a5af5..292b7168 100644 --- a/include/wimlib/wof.h +++ b/include/wimlib/wof.h @@ -34,7 +34,7 @@ #include "wimlib/compiler.h" #include "wimlib/types.h" -#ifdef __WIN32__ +#ifdef _WIN32 /* * The Windows Overlay Filesystem filter (WOF, a.k.a. wof.sys) is a filesystem @@ -425,6 +425,6 @@ wof_check_structs(void) STATIC_ASSERT(sizeof(struct WimOverlay_dat_entry_2) == 104); } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ #endif /* _WOF_H_ */ diff --git a/include/wimlib_tchar.h b/include/wimlib_tchar.h index 2e1f44e6..339b46d6 100644 --- a/include/wimlib_tchar.h +++ b/include/wimlib_tchar.h @@ -4,7 +4,7 @@ /* Functions to act on "tchar" strings, which have a platform-dependent encoding * and character size. */ -#ifdef __WIN32__ +#ifdef _WIN32 #include /* * For Windows builds, the "tchar" type will be 2 bytes and will be equivalent @@ -68,7 +68,7 @@ typedef wchar_t tchar; _wcserror_s((buf), (bufsize), (errnum)) # define trename win32_rename_replacement # define tglob win32_wglob -#else /* __WIN32__ */ +#else /* _WIN32 */ /* * For non-Windows builds, the "tchar" type will be one byte and will specify a * string encoded in UTF-8 with the additional possibility of surrogate @@ -127,6 +127,6 @@ typedef char tchar; # define trename rename # define taccess access # define tglob glob -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ #endif /* _WIMLIB_TCHAR_H */ diff --git a/programs/imagex-win32.c b/programs/imagex-win32.c index 6ff838ca..b72ae354 100644 --- a/programs/imagex-win32.c +++ b/programs/imagex-win32.c @@ -1,6 +1,6 @@ /* Windows-specific code for wimlib-imagex. */ -#ifndef __WIN32__ +#ifndef _WIN32 # error "This file contains Windows code" #endif diff --git a/programs/imagex.c b/programs/imagex.c index 1766ad41..e44ff276 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -48,10 +48,10 @@ #define WIMLIB_COMPRESSION_TYPE_INVALID (-1) -#ifdef __WIN32__ +#ifdef _WIN32 # include "imagex-win32.h" # define print_security_descriptor win32_print_security_descriptor -#else /* __WIN32__ */ +#else /* _WIN32 */ # include # include # define print_security_descriptor default_print_security_descriptor @@ -62,13 +62,13 @@ static inline void set_fd_to_binary_mode(int fd) #ifndef HAVE_GETOPT_LONG_ONLY # define getopt_long_only getopt_long #endif -#endif /* !__WIN32 */ +#endif /* !_WIN32 */ /* Don't confuse the user by presenting the mounting commands on Windows when * they will never work. However on UNIX-like systems we always present them, * even if WITH_FUSE is not defined at this point, as to not tie the build of * wimlib-imagex to a specific build of wimlib. */ -#ifdef __WIN32__ +#ifdef _WIN32 # define WIM_MOUNTING_SUPPORTED 0 #else # define WIM_MOUNTING_SUPPORTED 1 @@ -1055,12 +1055,12 @@ stdin_get_contents(size_t *len_ret) static tchar * translate_text_to_tstr(char *text, size_t num_bytes, size_t *num_tchars_ret) { -#ifndef __WIN32__ +#ifndef _WIN32 /* On non-Windows, assume an ASCII-compatible encoding, such as UTF-8. * */ *num_tchars_ret = num_bytes; return text; -#else /* !__WIN32__ */ +#else /* !_WIN32 */ /* On Windows, translate the text to UTF-16LE */ wchar_t *text_wstr; size_t num_wchars; @@ -1087,7 +1087,7 @@ translate_text_to_tstr(char *text, size_t num_bytes, size_t *num_tchars_ret) } *num_tchars_ret = num_wchars; return text_wstr; -#endif /* __WIN32__ */ +#endif /* _WIN32 */ } static tchar * @@ -1265,7 +1265,7 @@ imagex_progress_func(enum wimlib_progress_msg msg, * default installation. On UNIX-like systems, warn the * user when fixing the target of an absolute symbolic * link, so they know to disable this if they want. */ - #ifndef __WIN32__ + #ifndef _WIN32 imagex_printf(T("\nWARNING: Adjusted target of " "absolute symbolic link \"%"TS"\"\n" " (Use --norpfix to capture " @@ -1817,7 +1817,7 @@ imagex_apply(int argc, tchar **argv, int cmd) goto out_wimlib_free; } -#ifndef __WIN32__ +#ifndef _WIN32 { /* Interpret a regular file or block device target as an NTFS * volume. */ @@ -2040,7 +2040,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) template_image_name_or_num = optarg; } } - #ifdef __WIN32__ + #ifdef _WIN32 imagex_printf(T("[WARNING] '--update-of' is unreliable on Windows!\n")); #endif break; @@ -2278,7 +2278,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) goto out_free_wim; } -#ifndef __WIN32__ +#ifndef _WIN32 /* Detect if source is regular file or block device and set NTFS volume * capture mode. */ if (!source_list) { @@ -2721,7 +2721,7 @@ print_blobs(WIMStruct *wim) wimlib_iterate_lookup_table(wim, 0, print_resource, NULL); } -#ifndef __WIN32__ +#ifndef _WIN32 static void default_print_security_descriptor(const uint8_t *sd, size_t size) { @@ -4460,7 +4460,7 @@ static const struct imagex_command imagex_commands[] = { [CMD_VERIFY] = {T("verify"), imagex_verify}, }; -#ifdef __WIN32__ +#ifdef _WIN32 /* Can be a directory or source list file. But source list file is probably * a rare use case, so just say directory. */ @@ -4666,7 +4666,7 @@ static void recommend_man_page(int cmd, FILE *fp) { const tchar *format_str; -#ifdef __WIN32__ +#ifdef _WIN32 format_str = T("Some uncommon options are not listed;\n" "See %"TS".pdf in the doc directory for more details.\n"); #else @@ -4707,7 +4707,7 @@ usage_all(FILE *fp) recommend_man_page(CMD_NONE, fp); } -#ifdef __WIN32__ +#ifdef _WIN32 extern int wmain(int argc, wchar_t **argv); #define main wmain #endif diff --git a/src/blob_table.c b/src/blob_table.c index cec5b498..d562e2c6 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -132,7 +132,7 @@ clone_blob_descriptor(const struct blob_descriptor *old) if (new->file_on_disk == NULL) goto out_free; break; -#ifdef __WIN32__ +#ifdef _WIN32 case BLOB_IN_WINDOWS_FILE: new->windows_file = clone_windows_file(old->windows_file); break; @@ -184,7 +184,7 @@ blob_release_location(struct blob_descriptor *blob) (void*)&blob->attached_buffer); FREE(blob->file_on_disk); break; -#ifdef __WIN32__ +#ifdef _WIN32 case BLOB_IN_WINDOWS_FILE: free_windows_file(blob->windows_file); break; @@ -462,7 +462,7 @@ cmp_blobs_by_sequential_order(const void *p1, const void *p2) /* Compare files by path: just a heuristic that will place files * in the same directory next to each other. */ return tstrcmp(blob1->file_on_disk, blob2->file_on_disk); -#ifdef __WIN32__ +#ifdef _WIN32 case BLOB_IN_WINDOWS_FILE: return cmp_windows_files(blob1->windows_file, blob2->windows_file); #endif diff --git a/src/dentry.c b/src/dentry.c index 9e175f7e..42241ef2 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -607,7 +607,7 @@ collate_dentry_names(const struct avl_tree_node *n1, * WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE or * WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE to wimlib_global_init(). */ bool default_ignore_case = -#ifdef __WIN32__ +#ifdef _WIN32 true #else false diff --git a/src/error.c b/src/error.c index 22352f53..a29d9414 100644 --- a/src/error.c +++ b/src/error.c @@ -68,7 +68,7 @@ wimlib_vmsg(const tchar *tag, const tchar *format, va_list va, bool perror) T("unknown error (errno=%d)"), errno_save); } - #ifdef WIN32 + #ifdef _WIN32 if (errno_save == EBUSY) tstrcpy(buf, T("Resource busy")); #endif @@ -149,7 +149,7 @@ wimlib_set_error_file_by_name(const tchar *path) { FILE *fp; -#ifdef __WIN32__ +#ifdef _WIN32 fp = win32_open_logfile(path); #else fp = fopen(path, "a"); diff --git a/src/extract.c b/src/extract.c index 0e5d4ec4..7db0d288 100644 --- a/src/extract.c +++ b/src/extract.c @@ -387,7 +387,7 @@ create_temporary_file(struct filedes *fd_ret, tchar **name_ret) tchar *name; int raw_fd; -#ifdef __WIN32__ +#ifdef _WIN32 retry: name = _wtempnam(NULL, L"wimlib"); if (!name) { @@ -400,7 +400,7 @@ retry: FREE(name); goto retry; } -#else /* __WIN32__ */ +#else /* _WIN32 */ const char *tmpdir = getenv("TMPDIR"); if (!tmpdir) tmpdir = P_tmpdir; @@ -409,7 +409,7 @@ retry: return WIMLIB_ERR_NOMEM; sprintf(name, "%s/wimlibXXXXXX", tmpdir); raw_fd = mkstemp(name); -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ if (raw_fd < 0) { ERROR_WITH_ERRNO("Failed to create temporary file " @@ -804,7 +804,7 @@ destroy_blob_list(struct list_head *blob_list) FREE(blob->blob_extraction_targets); } -#ifdef __WIN32__ +#ifdef _WIN32 static const utf16lechar replacement_char = cpu_to_le16(0xfffd); #else static const utf16lechar replacement_char = cpu_to_le16('?'); @@ -819,7 +819,7 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix) return true; for (i = 0; i < num_chars; i++) { switch (le16_to_cpu(name[i])) { - #ifdef __WIN32__ + #ifdef _WIN32 case '\x01'...'\x1F': case '\\': case ':': @@ -1467,7 +1467,7 @@ select_apply_operations(int extract_flags) if (extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) return &ntfs_3g_apply_ops; #endif -#ifdef __WIN32__ +#ifdef _WIN32 return &win32_apply_ops; #else return &unix_apply_ops; @@ -1625,7 +1625,7 @@ mkdir_if_needed(const tchar *target) if (errno == EEXIST) return 0; -#ifdef __WIN32__ +#ifdef _WIN32 /* _wmkdir() fails with EACCES if called on a drive root directory. */ if (errno == EACCES) return 0; @@ -1664,7 +1664,7 @@ check_extract_flags(const WIMStruct *wim, int *extract_flags_p) #endif if (extract_flags & WIMLIB_EXTRACT_FLAG_WIMBOOT) { -#ifdef __WIN32__ +#ifdef _WIN32 if (!wim->filename) return WIMLIB_ERR_NO_FILENAME; #else @@ -1678,7 +1678,7 @@ check_extract_flags(const WIMStruct *wim, int *extract_flags_p) WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K | WIMLIB_EXTRACT_FLAG_COMPACT_LZX)) { - #ifdef __WIN32__ + #ifdef _WIN32 int count = 0; count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K) != 0); count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K) != 0); @@ -1871,7 +1871,7 @@ extract_single_image(WIMStruct *wim, int image, } static const tchar * const filename_forbidden_chars = -#ifdef __WIN32__ +#ifdef _WIN32 T("<>:\"/\\|?*"); #else T("/"); diff --git a/src/file_io.c b/src/file_io.c index 8fbd01f9..c1665c6d 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -30,7 +30,7 @@ #include "wimlib/file_io.h" #include "wimlib/util.h" -#ifdef __WIN32__ +#ifdef _WIN32 # include "wimlib/win32.h" # define read win32_read # define write win32_write diff --git a/src/mount_image.c b/src/mount_image.c index c90911e2..c7898d3d 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -33,7 +33,7 @@ #ifdef WITH_FUSE -#ifdef __WIN32__ +#ifdef _WIN32 # error "FUSE mount not supported on Windows! Please configure --without-fuse" #endif @@ -2515,7 +2515,7 @@ wimlib_unmount_image_with_progress(const char *dir, int unmount_flags, static int mount_unsupported_error(void) { -#if defined(__WIN32__) +#ifdef _WIN32 ERROR("Sorry-- Mounting WIM images is not supported on Windows!"); #else ERROR("wimlib was compiled with --without-fuse, which disables support " diff --git a/src/reparse.c b/src/reparse.c index da8642f8..74bb56fd 100644 --- a/src/reparse.c +++ b/src/reparse.c @@ -156,7 +156,7 @@ make_link_reparse_point(const struct link_reparse_point *link, } /* UNIX symlink <=> Windows reparse point translation */ -#ifndef __WIN32__ +#ifndef _WIN32 /* Retrieve the inode's reparse point buffer into @rpbuf and @rpbuflen_ret. * This gets the reparse data from @blob if specified, otherwise from the @@ -442,4 +442,4 @@ out_free_target: return ret; } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ diff --git a/src/resource.c b/src/resource.c index a643ce03..0036c1b9 100644 --- a/src/resource.c +++ b/src/resource.c @@ -778,7 +778,7 @@ read_blob_prefix(const struct blob_descriptor *blob, u64 size, #ifdef WITH_NTFS_3G [BLOB_IN_NTFS_VOLUME] = read_ntfs_attribute_prefix, #endif - #ifdef __WIN32__ + #ifdef _WIN32 [BLOB_IN_WINDOWS_FILE] = read_windows_file_prefix, #endif }; diff --git a/src/solid.c b/src/solid.c index 35f2eef0..ecb7d0e8 100644 --- a/src/solid.c +++ b/src/solid.c @@ -206,7 +206,7 @@ sort_blob_list_for_solid_compression(struct list_head *blob_list) blob_table.capacity]); break; case BLOB_IN_FILE_ON_DISK: - #ifdef __WIN32__ + #ifdef _WIN32 case BLOB_IN_WINDOWS_FILE: #endif blob_set_solid_sort_name_from_inode(blob, blob->file_inode); diff --git a/src/test_support.c b/src/test_support.c index 5c566dcb..2478f246 100644 --- a/src/test_support.c +++ b/src/test_support.c @@ -126,7 +126,7 @@ is_valid_windows_filename_char(utf16lechar c) static inline bool is_valid_filename_char(utf16lechar c) { -#ifdef __WIN32__ +#ifdef _WIN32 return is_valid_windows_filename_char(c); #else return c != cpu_to_le16('\0') && c != cpu_to_le16('/'); @@ -385,7 +385,7 @@ generate_random_security_descriptor(void *_desc, struct generation_context *ctx) static bool am_root(void) { -#ifdef __WIN32__ +#ifdef _WIN32 return false; #else return (getuid() == 0); @@ -395,7 +395,7 @@ am_root(void) static u32 generate_uid(void) { -#ifdef __WIN32__ +#ifdef _WIN32 return 0; #else if (am_root()) @@ -407,7 +407,7 @@ generate_uid(void) static u32 generate_gid(void) { -#ifdef __WIN32__ +#ifdef _WIN32 return 0; #else if (am_root()) @@ -416,7 +416,7 @@ generate_gid(void) #endif } -#ifdef __WIN32__ +#ifdef _WIN32 # ifndef S_IFLNK # define S_IFLNK 0120000 # endif @@ -475,7 +475,7 @@ set_random_xattrs(struct wim_inode *inode) struct wim_xattr_entry *entry = (void *)entries; size_t entries_size; struct wimlib_unix_data unix_data; -#ifdef __WIN32__ +#ifdef _WIN32 const char *prefix = ""; #else const char *prefix = "user."; @@ -501,7 +501,7 @@ set_random_xattrs(struct wim_inode *inode) int value_len = rand32() % 64; u8 *p; - #ifdef __WIN32__ + #ifdef _WIN32 if (value_len == 0) value_len++; #endif @@ -523,7 +523,7 @@ set_random_xattrs(struct wim_inode *inode) *p++ = 'A' + i; for (int j = 1; j < name_len; j++) { do { - #ifdef __WIN32__ + #ifdef _WIN32 *p = 'A' + rand8() % 26; #else *p = rand8(); diff --git a/src/timestamp.c b/src/timestamp.c index 51046cdb..1e0eef3e 100644 --- a/src/timestamp.c +++ b/src/timestamp.c @@ -70,7 +70,7 @@ wim_timestamp_to_wimlib_timespec(u64 timestamp, struct wimlib_timespec *wts, *high_part_ret = sec >> 32; } -#ifdef __WIN32__ +#ifdef _WIN32 static _unused_attribute void check_sizeof_time_t(void) { @@ -127,7 +127,7 @@ now_as_wim_timestamp(void) gettimeofday(&tv, NULL); return timeval_to_wim_timestamp(&tv); } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ /* Translate a WIM timestamp into a human-readable string. */ void diff --git a/src/unix_capture.c b/src/unix_capture.c index f9fad4a3..a6c56932 100644 --- a/src/unix_capture.c +++ b/src/unix_capture.c @@ -19,7 +19,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifndef __WIN32__ +#ifndef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -688,4 +688,4 @@ unix_build_dentry_tree(struct wim_dentry **root_ret, root_disk_path, params); } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ diff --git a/src/update_image.c b/src/update_image.c index f4affbdd..2964b717 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -1234,7 +1234,7 @@ check_add_command(struct wimlib_update_command *cmd, } #endif -#ifdef __WIN32__ +#ifdef _WIN32 /* Check for flags not supported on Windows. */ if (add_flags & WIMLIB_ADD_FLAG_UNIX_DATA) { ERROR("Capturing UNIX-specific data is not supported on Windows"); diff --git a/src/util.c b/src/util.c index 0fe3d4e4..fe129286 100644 --- a/src/util.c +++ b/src/util.c @@ -106,7 +106,7 @@ wimlib_strdup(const char *str) return memdup(str, strlen(str) + 1); } -#ifdef __WIN32__ +#ifdef _WIN32 wchar_t * wimlib_wcsdup(const wchar_t *str) { @@ -174,7 +174,7 @@ void *mempcpy(void *dst, const void *src, size_t n) * Random number generation **************************/ -#ifndef __WIN32__ +#ifndef _WIN32 /* * Generate @n cryptographically secure random bytes (thread-safe) * @@ -231,7 +231,7 @@ try_dev_urandom: } while (n != 0); close(fd); } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ /* * Generate @n cryptographically secure random alphanumeric characters @@ -275,7 +275,7 @@ get_random_alnum_chars(tchar *p, size_t n) * System information ************************/ -#ifndef __WIN32__ +#ifndef _WIN32 unsigned get_available_cpus(void) { @@ -286,9 +286,9 @@ get_available_cpus(void) } return n; } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ -#ifndef __WIN32__ +#ifndef _WIN32 u64 get_available_memory(void) { @@ -311,4 +311,4 @@ default_size: WARNING("Failed to determine available memory; assuming 1 GiB"); return (u64)1 << 30; } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ diff --git a/src/wim.c b/src/wim.c index b1902f41..e9a6c8eb 100644 --- a/src/wim.c +++ b/src/wim.c @@ -980,7 +980,7 @@ wimlib_global_init(int init_flags) init_cpu_features(); xml_global_init(); -#ifdef __WIN32__ +#ifdef _WIN32 ret = win32_global_init(init_flags); if (ret) goto out_unlock; @@ -1011,7 +1011,7 @@ wimlib_global_cleanup(void) goto out_unlock; xml_global_cleanup(); -#ifdef __WIN32__ +#ifdef _WIN32 win32_global_cleanup(); #endif diff --git a/src/wimboot.c b/src/wimboot.c index 3943470c..3219758f 100644 --- a/src/wimboot.c +++ b/src/wimboot.c @@ -27,7 +27,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -1120,4 +1120,4 @@ wimboot_set_pointer(HANDLE h, return true; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/win32_apply.c b/src/win32_apply.c index a1301d64..5011efff 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -19,7 +19,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -3350,4 +3350,4 @@ const struct apply_operations win32_apply_ops = { .context_size = sizeof(struct win32_apply_ctx), }; -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/win32_capture.c b/src/win32_capture.c index e4a59c3a..f9fae537 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -21,7 +21,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -3046,4 +3046,4 @@ out: return ret; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/win32_common.c b/src/win32_common.c index 47f2df30..cb3468ac 100644 --- a/src/win32_common.c +++ b/src/win32_common.c @@ -19,7 +19,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -407,4 +407,4 @@ winnt_fsctl(HANDLE h, u32 code, const void *in, u32 in_size, return status; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/win32_replacements.c b/src/win32_replacements.c index 566cba9c..f6a5a6e1 100644 --- a/src/win32_replacements.c +++ b/src/win32_replacements.c @@ -20,7 +20,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -770,4 +770,4 @@ now_as_wim_timestamp(void) return ((u64)ft.dwHighDateTime << 32) | ft.dwLowDateTime; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/win32_vss.c b/src/win32_vss.c index 04e81acb..6a74b099 100644 --- a/src/win32_vss.c +++ b/src/win32_vss.c @@ -20,7 +20,7 @@ * along with this file; if not, see http://www.gnu.org/licenses/. */ -#ifdef __WIN32__ +#ifdef _WIN32 #ifdef HAVE_CONFIG_H # include "config.h" @@ -516,4 +516,4 @@ out: return ret; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ diff --git a/src/write.c b/src/write.c index 5c0c2130..2fa83f77 100644 --- a/src/write.c +++ b/src/write.c @@ -3274,7 +3274,7 @@ overwrite_wim_via_tmpfile(WIMStruct *wim, int write_flags, unsigned num_threads) if (ret) { ERROR_WITH_ERRNO("Failed to rename `%"TS"' to `%"TS"'", tmpfile, wim->filename); - #ifdef __WIN32__ + #ifdef _WIN32 if (ret < 0) #endif { diff --git a/tests/wlfuzz.c b/tests/wlfuzz.c index 7b3589b9..e9880a26 100644 --- a/tests/wlfuzz.c +++ b/tests/wlfuzz.c @@ -66,7 +66,7 @@ #endif #include -#ifdef __WIN32__ +#ifdef _WIN32 # include # include # include @@ -119,7 +119,7 @@ assertion_failed(int line, const char *format, ...) static void change_to_temporary_directory(void) { -#ifdef __WIN32__ +#ifdef _WIN32 ASSERT(SetCurrentDirectory(L"E:\\"), "failed to change directory to E:\\"); #else @@ -186,7 +186,7 @@ create_ntfs_volume(const char *name) } #endif /* WITH_NTFS_3G */ -#ifdef __WIN32__ +#ifdef _WIN32 extern WINAPI NTSTATUS NtQueryDirectoryFile (HANDLE FileHandle, HANDLE Event, @@ -300,7 +300,7 @@ delete_directory_tree(const wchar_t *name) ASSERT(GetFileAttributes(name) == 0xFFFFFFFF, "Deletion didn't work!"); } -#else /* __WIN32__ */ +#else /* _WIN32 */ static void delete_directory_tree_recursive(int dirfd, const char *name) @@ -332,7 +332,7 @@ delete_directory_tree(const tchar *name) delete_directory_tree_recursive(AT_FDCWD, name); } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ static uint32_t rand32(void) @@ -411,7 +411,7 @@ get_image_count(WIMStruct *wim) return info.image_count; } -#ifdef __WIN32__ +#ifdef _WIN32 static bool is_wimboot_capable(WIMStruct *wim) { @@ -426,7 +426,7 @@ is_wimboot_capable(WIMStruct *wim) (info.compression_type == WIMLIB_COMPRESSION_TYPE_LZX && info.chunk_size == 32768)); } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ static void overwrite_wim(WIMStruct *wim) @@ -778,15 +778,15 @@ op__apply_and_capture_test(void) } else #endif { -#ifdef __WIN32__ +#ifdef _WIN32 printf("applying in Windows mode\n"); cmp_flags |= WIMLIB_CMP_FLAG_WINDOWS_MODE; -#else /* __WIN32__ */ +#else /* _WIN32 */ printf("applying in UNIX mode\n"); extract_flags |= WIMLIB_EXTRACT_FLAG_UNIX_DATA; add_flags |= WIMLIB_ADD_FLAG_UNIX_DATA; cmp_flags |= WIMLIB_CMP_FLAG_UNIX_MODE; -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ } add_flags |= WIMLIB_ADD_FLAG_NORPFIX; CHECK_RET(wimlib_extract_image(wim, image, TMP_TARGET_NAME, @@ -810,7 +810,7 @@ op__apply_and_capture_test(void) wimlib_free(wim); } -#ifdef __WIN32__ +#ifdef _WIN32 /* Enumerate and unregister all backing WIMs from the specified volume */ static void @@ -931,7 +931,7 @@ op__wimboot_test(void) wimlib_free(wim); wimlib_free(wim2); } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ static int is_solid_resource(const struct wimlib_resource_entry *resource, void *_ctx) @@ -1039,12 +1039,12 @@ static const operation_func operation_table[] = { op__apply_and_capture_test, op__split_test, op__set_compression_level, -#ifdef __WIN32__ +#ifdef _WIN32 op__wimboot_test, #endif }; -#ifdef __WIN32__ +#ifdef _WIN32 extern int wmain(int argc, wchar_t **argv); #define main wmain #endif -- 2.43.0