Skip to content
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

win32: move usleep definition to unistd.h #765

Merged
merged 1 commit into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/gdbserver/gdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ int main(int argc, char** argv) {

do {
if (serve(sl, &state)) {
sleep (1); // don't go bezurk if serve returns with error
}
usleep (1 * 1000); // don't go bezurk if serve returns with error
}

/* in case serve() changed the connection */
sl = connected_stlink;
Expand Down
6 changes: 4 additions & 2 deletions src/mingw/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ char *win32_strsep (char **stringp, const char *delim)
}

#ifndef STLINK_HAVE_UNISTD_H
void usleep(DWORD waitTime)
int usleep(unsigned int waitTime)
{
if (waitTime >= 1000)
{
Expand All @@ -288,7 +288,7 @@ void usleep(DWORD waitTime)
SetWaitableTimer(timer, &dueTime, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
return;
return 0;
}
LARGE_INTEGER perf_cnt, start, now;

Expand All @@ -298,6 +298,8 @@ void usleep(DWORD waitTime)
do {
QueryPerformanceCounter((LARGE_INTEGER*) &now);
} while ((now.QuadPart - start.QuadPart) / (float)perf_cnt.QuadPart * 1000 * 1000 < waitTime);

return 0;
}
#endif

Expand Down
5 changes: 0 additions & 5 deletions src/mingw/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,4 @@ char *win32_strsep(char **stringp, const char *delim);
ssize_t win32_read_socket(SOCKET fd, void *buf, int n);
ssize_t win32_write_socket(SOCKET fd, void *buf, int n);

#ifndef STLINK_HAVE_UNISTD_H
static inline void sleep(unsigned ms) { Sleep(ms); }
void usleep(DWORD waitTime);
#endif

#endif //defined(__MINGW32__) || defined(_MSC_VER)
4 changes: 4 additions & 0 deletions src/win32/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

#ifndef STLINK_HAVE_UNISTD_H
int usleep(unsigned int waitTime);
#endif

#endif /* unistd.h */