]> wimlib.net Git - wimlib/commitdiff
Consistently use _WIN32 instead of __WIN32__
authorEric Biggers <ebiggers3@gmail.com>
Mon, 20 Mar 2023 03:59:17 +0000 (20:59 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 20 Mar 2023 04:06:56 +0000 (21:06 -0700)
_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.

38 files changed:
include/wimlib/apply.h
include/wimlib/blob_table.h
include/wimlib/compiler.h
include/wimlib/file_io.h
include/wimlib/glob.h
include/wimlib/paths.h
include/wimlib/progress.h
include/wimlib/reparse.h
include/wimlib/scan.h
include/wimlib/util.h
include/wimlib/win32.h
include/wimlib/wof.h
include/wimlib_tchar.h
programs/imagex-win32.c
programs/imagex.c
src/blob_table.c
src/dentry.c
src/error.c
src/extract.c
src/file_io.c
src/mount_image.c
src/reparse.c
src/resource.c
src/solid.c
src/test_support.c
src/timestamp.c
src/unix_capture.c
src/update_image.c
src/util.c
src/wim.c
src/wimboot.c
src/win32_apply.c
src/win32_capture.c
src/win32_common.c
src/win32_replacements.c
src/win32_vss.c
src/write.c
tests/wlfuzz.c

index 7813aee13d7df14fa101770abfeecc7b95c62c25..b290693ec2d25bb12afdd990a693f40d21777711 100644 (file)
@@ -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;
index 952b6dd0c08253fea3042640d6267eda326fa9df..9bb54b542819992d66aeb5d94657fba8e177d751 100644 (file)
@@ -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
index 742f3bfce1a0302fea405e77b11180a20890ffbe..283152bd7aae82ebd1b112a530aa90ad0cfc1080 100644 (file)
@@ -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")))
 /* 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)    \
index 61ae78b9e270aee622376346a68e0eff7ad18af0..7cfe2cd87b56c9c5494201c7f8852841ffa9a43c 100644 (file)
@@ -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
 
index 1027ec7cb316af092298c0e6d3b47c6219669430..5455be2661d75de45a9692cfb46932d64eac88d1 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _WIMLIB_GLOB_H
 #define _WIMLIB_GLOB_H
 
-#ifndef __WIN32__
+#ifndef _WIN32
 #  include <glob.h>
 #else
 #include <stddef.h>
@@ -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 */
index 6ff7193e39173e77695c621fb38dc9c17deb837a..764bdcfba025dbcec02011a2c81f8a2ce6df7b80 100644 (file)
@@ -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
index 6d39b7e49804fb0089c8234985aa51e978108a00..062656c5c6b86ec11a28105443182a615cdfe661 100644 (file)
@@ -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
index dce19a22130087ec1cc9475a88b060aab513dbdb..04592cec60cd866145c5a62b731d75ef41611fce 100644 (file)
@@ -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,
index fbe304e8d41734958f4e66cb8c0b8f09e9fa9fcc..bae72c75474d3014a36d58fc965bc60abd10ef75 100644 (file)
@@ -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,
index 350fbbb592d521530b3e82518bf3f1fcfbfb9b1b..55fc9e4a35030731ad0e45508a340ebc92f7e5d3 100644 (file)
@@ -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
index 71a77107a837f5678ae16a20f2b4ac8c164c96cb..164620963affe2891ed4a89a8584f078e9d370cb 100644 (file)
@@ -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 */
index 9d5a5af5c5bd1ab5290432dd3e8aea89d6e92eca..292b7168a56e83852d98a253d0efd980950da804 100644 (file)
@@ -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_ */
index 2e1f44e6cce55b3c64f04e2ea8fdfa5ad86397dc..339b46d6bdbdfe40db4d731f2112de7f8f0a3fc4 100644 (file)
@@ -4,7 +4,7 @@
 /* Functions to act on "tchar" strings, which have a platform-dependent encoding
  * and character size. */
 
-#ifdef __WIN32__
+#ifdef _WIN32
 #include <wchar.h>
 /*
  * 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 */
index 6ff838ca63e845a7053dbc7a2a984b9fafb9a491..b72ae354f7401ef1124ef65b09be629f9ac99c12 100644 (file)
@@ -1,6 +1,6 @@
 /* Windows-specific code for wimlib-imagex.  */
 
-#ifndef __WIN32__
+#ifndef _WIN32
 #  error "This file contains Windows code"
 #endif
 
index 1766ad414e9aabae8901a5b543e83f9a53d6cea4..e44ff276b49414526d827b1d40d7b3e2bb4a1ff6 100644 (file)
 
 #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 <getopt.h>
 #  include <langinfo.h>
 #  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
index cec5b4986337f3cc878963957cc687d2f616870b..d562e2c6cf6ff363abe21e8e70c47a32adbca0ca 100644 (file)
@@ -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
index 9e175f7ea5391841ca95e8e26be574e7894b77ac..42241ef28c945b51dc9aa942d2e469cda0bc429f 100644 (file)
@@ -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
index 22352f533829003f6ae92c166810c67ea644f125..a29d9414efc65775a314cd8b057af52e065e37eb 100644 (file)
@@ -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");
index 0e5d4ec4c900c1aab13d23bdd4f905c51afb6b8e..7db0d2889d162aea8867da877efafbda2097afd4 100644 (file)
@@ -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("/");
index 8fbd01f9669040b9b1dcf6f5abe2ad9e81478208..c1665c6dccb41c7d53d4806fad58629cd9824a92 100644 (file)
@@ -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
index c90911e2b0bd6e814ef5a4160a9504f7a654b97a..c7898d3df0358fd53158554d584a452b1808ccd3 100644 (file)
@@ -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 "
index da8642f8561fd74696726a11e583eedeb3c9f219..74bb56fd22e258a71d9e4105430d4b2206405794 100644 (file)
@@ -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 */
index a643ce0340c91e320b85e331c7da1bce7dedd135..0036c1b90377823ce4dee8502a70323289c4ba04 100644 (file)
@@ -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
        };
index 35f2eef0a20695c3a279af668a1c62ae22a4b3ed..ecb7d0e81fef59d2013a282a7c5d8be436803d15 100644 (file)
@@ -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);
index 5c566dcb25db164e5fc9a1d42e550df017e6d6fe..2478f2466c3e147b2f91b57ed599f9d4bca6e5b2 100644 (file)
@@ -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();
index 51046cdb68084048df29ab185ecd6f03cbeaba33..1e0eef3e113651d22fc30f62730ccf8fd737deee 100644 (file)
@@ -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
index f9fad4a33ce1a1ece10237d9c90d452743019a3e..a6c569323757ee14e68ef1e0012570ddb936e996 100644 (file)
@@ -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 */
index f4affbddcd309ab986897d449da017fcdf9ba785..2964b71778f49099da55ceaa991be2fdf6161d5f 100644 (file)
@@ -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");
index 0fe3d4e4582026b3ea9aaae6f375fdb7f8a73578..fe1292860f191d790db6fc37fe6f1c06193909ba 100644 (file)
@@ -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 */
index b1902f41b6c1898f25072d80b678ce1661c3d791..e9a6c8eba1ca665d619272e82c9eb92c1ed2faf8 100644 (file)
--- 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
 
index 3943470c8f439d1e1b6e7ff65d7609da57df5fff..3219758fa6507ea0ae1d077a442ab85ccf495387 100644 (file)
@@ -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 */
index a1301d646290f4d8671428119698e3a41871e619..5011efffbf1dcf4e14747ab6c77d62353bb0e373 100644 (file)
@@ -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 */
index e4a59c3aa49c607cadf060be11e6b8f7fb2032db..f9fae537f9afa6ca1549e9709b5742ed81935a9b 100644 (file)
@@ -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 */
index 47f2df307375b5591a770e97b42ff41774f2160b..cb3468ac550fd6fa49fbea3fdcec7d440c2a4801 100644 (file)
@@ -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 */
index 566cba9ce3a3419af9f9d9b76bd85af0da4f7485..f6a5a6e1dda10c2c29ceccc37acb870fbbf1858b 100644 (file)
@@ -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 */
index 04e81acb2e25782d962fbb0dba94b8a33529e198..6a74b099ad1be4a26078f7c43320162f0c4c74c5 100644 (file)
@@ -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 */
index 5c0c21308838a04b7ab706196685becae13d7fcd..2fa83f775c975bdb0ff3fe14766377b384517e77 100644 (file)
@@ -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
                {
index 7b3589b99e0fe4dc4e235c5375de35a07390ec18..e9880a260023c668377c90a88cbc73d86c5a0208 100644 (file)
@@ -66,7 +66,7 @@
 #endif
 #include <unistd.h>
 
-#ifdef __WIN32__
+#ifdef _WIN32
 #  include <windows.h>
 #  include <winternl.h>
 #  include <ntstatus.h>
@@ -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