Skip to content

Base: reorder includes for Windows (NFCI) #2623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions CoreFoundation/Base.subproj/CoreFoundation_Prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ typedef char * Class;
#include <pthread.h>
#endif

#if TARGET_OS_WIN32
#define BOOL WINDOWS_BOOL

#define MAXPATHLEN MAX_PATH
#undef MAX_PATH
#undef INVALID_HANDLE_VALUE

#define WIN32_LEAN_AND_MEAN

#ifndef WINVER
#define WINVER 0x0601
#endif

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#endif

// The order of these includes is important
#define FD_SETSIZE 1024
#include <winsock2.h>
#include <windows.h>
#include <time.h>
Copy link
Member

@3405691582 3405691582 Jan 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget time.h is included adjacent to mach_absolute_time.

(Not sure if you need to redef BOOL for time.h, or whether it's just simpler to include time.h twice here.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That needed to be shuffled due to the inclusion of Windows.h.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is: can you omit it here again, considering now time.h is included a second time below windows.h, or is there some other reason preventing that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see; I'll do that as a follow up. The time.h was moved since it was in the block.


#undef BOOL

#endif


/* This macro creates some helper functions which are useful in dealing with libdispatch:
* __ PREFIX Queue -- manages and returns a singleton serial queue
Expand Down Expand Up @@ -261,10 +288,6 @@ CF_INLINE size_t malloc_size(void *memblock) {

#if TARGET_OS_WIN32

#define MAXPATHLEN MAX_PATH
#undef MAX_PATH
#undef INVALID_HANDLE_VALUE

// Defined for source compatibility
#define ino_t _ino_t
#define off_t _off_t
Expand All @@ -291,26 +314,6 @@ CF_EXPORT int _NS_chdir(const char *name);
CF_EXPORT int _NS_mkstemp(char *name, int bufSize);
CF_EXPORT int _NS_access(const char *name, int amode);

#define BOOL WINDOWS_BOOL

#define WIN32_LEAN_AND_MEAN

#ifndef WINVER
#define WINVER 0x0601
#endif

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#endif

// The order of these includes is important
#define FD_SETSIZE 1024
#include <winsock2.h>
#include <windows.h>
#include <time.h>

#undef BOOL

#define __PRETTY_FUNCTION__ __FUNCTION__

#define malloc_default_zone() (void *)0
Expand Down