-
Notifications
You must be signed in to change notification settings - Fork 471
implemented getprogname() for Windows #367
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
Conversation
src/shims/getprogname.c
Outdated
PVOID *lpContext); | ||
|
||
char * | ||
getprogname_win32(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move below to aovid having to do a forward.
pleas fix indent, and this function should be called getprogname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also return const char *
src/shims/getprogname.h
Outdated
@@ -30,13 +30,19 @@ | |||
extern const char *__progname; | |||
#endif /* __ANDROID */ | |||
|
|||
#if defined(_WIN32) | |||
char* getprogname_win32(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char *getprogname_win32
src/shims/getprogname.c
Outdated
return progname; | ||
} | ||
|
||
static BOOL CALLBACK getprogname_init_once_handler( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be written (with tabs indent):
static BOOL CALLBACK
getprogname_init_once_handler(PINIT_ONCE InitOnce, PVOID Parameter,
PVOID *lpContext)
{
...
src/shims/getprogname.c
Outdated
progname[0] = '\0'; | ||
return TRUE; | ||
} else { | ||
char * filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const char *filename;
I thought that libbsd has an implementation of this function. Can we not just use that? |
Not for Windows :( |
The lack of an actually functioning getprogname() implementation In libbsd on Windows is one problem that I see with the libbsd solution. But there are additional problems: I've identified 3 major road blocks to making libdispatch work on Windows: a) missing getprogname() implementation b) missing TAILQ macros c) missing event backend implementation libbsd doesn't help with (a) and (c) because it doesn't come with a working getprogname(), kevent nor epoll implementation for Windows. It would only help to solve issue (b). Except that issue (b) is trivial enough to solve in the context of libdispatch itself. The general problem that I see with adding 3rd party dependencies to Swift in the context of Windows is that:
So I would vastly prefer that libdispatch would just provide its own implementation of the necessary getprogname() and TAILQ macros instead of dragging libbsd in just for that. |
@MadCoder updated patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only some minor spacing remarks, will merge
src/shims/getprogname.c
Outdated
progname[0] = '\0'; | ||
return TRUE; | ||
} else { | ||
const char * filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the space after the star
src/shims/getprogname.c
Outdated
getprogname(void) | ||
{ | ||
(void) InitOnceExecuteOnce(&getprogname_init_once, | ||
getprogname_init_once_handler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be 2 indents from the base line, and remove the space after the cast.
src/shims/getprogname.h
Outdated
@@ -30,6 +30,10 @@ | |||
extern const char *__progname; | |||
#endif /* __ANDROID */ | |||
|
|||
#if defined(_WIN32) | |||
const char* getprogname(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const char *progname
(mind the spaces)
cc @MadCoder fixed spacing |
@swift-ci please test |
implemented getprogname() for Windows Signed-off-by: Kim Topley <ktopley@apple.com>
We use GetModuleFileName() to get the filename of the process. InitOnceExecuteOnce() is used to do this once per app run.