* [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
@ 2015-05-07 3:31 Bruce Cran
2015-05-07 16:59 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Cran @ 2015-05-07 3:31 UTC (permalink / raw)
To: fio@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
I've attached a patch that adds ctime_r to the Windows build and an
empty ioctl.h header that the build appears to need now. There are
linker errors after building the fio binary - I guess the other programs
need the Windows posix.c linked in? I'm not sure how the
configure/build system works now, so I wasn't able to update it.
--
Bruce
[-- Attachment #2: 0001-Add-Windows-ctime_r-implementation-and-add-empty-ioc.patch --]
[-- Type: text/plain, Size: 2442 bytes --]
From ca8693bb5af23fc0133fa3267f8d0cc5c8d25600 Mon Sep 17 00:00:00 2001
From: Bruce Cran <bruce.cran@gmail.com>
Date: Wed, 6 May 2015 16:30:46 -0600
Subject: [PATCH] Add Windows ctime_r implementation and add empty ioctl.h
header
stat.c now uses ctime_r(), so add an implementation for Windows.
It's expected that ioctl.h exists on each platform, even if it's
not used: add an empty file on Windows.
---
os/windows/posix.c | 24 ++++++++++++++++++++++++
os/windows/posix/include/sys/ioctl.h | 7 +++++++
2 files changed, 31 insertions(+)
create mode 100644 os/windows/posix/include/sys/ioctl.h
diff --git a/os/windows/posix.c b/os/windows/posix.c
index d238c64..41fc480 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -229,6 +229,30 @@ char *dlerror(void)
return dl_error;
}
+/* Copied from http://blogs.msdn.com/b/joshpoley/archive/2007/12/19/date-time-formats-and-conversions.aspx */
+void Time_tToSystemTime(time_t dosTime, SYSTEMTIME *systemTime)
+{
+ LARGE_INTEGER jan1970FT;
+ LARGE_INTEGER utcFT;
+ jan1970FT.QuadPart = 116444736000000000LL; // january 1st 1970
+ utcFT.QuadPart = ((unsigned __int64)dosTime) * 10000000 + jan1970FT.QuadPart;
+
+ FileTimeToSystemTime((FILETIME*)&utcFT, systemTime);
+}
+
+char* ctime_r(const time_t *t, char *buf)
+{
+ SYSTEMTIME systime;
+ const char * const dayOfWeek[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
+ const char * const monthOfYear[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+ Time_tToSystemTime(*t, &systime);
+ /* We don't know how long `buf` is, but assume it's rounded up from the minimum of 25 to 32 */
+ StringCchPrintfA(buf, 32, "%s %s %d %02d:%02d:%02d %04d", dayOfWeek[systime.wDayOfWeek - 1], monthOfYear[systime.wMonth - 1],
+ systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wYear);
+ return buf;
+}
+
int gettimeofday(struct timeval *restrict tp, void *restrict tzp)
{
FILETIME fileTime;
diff --git a/os/windows/posix/include/sys/ioctl.h b/os/windows/posix/include/sys/ioctl.h
new file mode 100644
index 0000000..a42247d
--- /dev/null
+++ b/os/windows/posix/include/sys/ioctl.h
@@ -0,0 +1,7 @@
+#ifndef IOCTL_H
+#define IOCTL_H
+
+/* This file is empty since it only needs to exist on Windows
+ but isn't otherwise used */
+
+#endif /* IOCTL_H */
\ No newline at end of file
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 3:31 [PATCH] Add Windows ctime_r implementation and empty ioctl.h header Bruce Cran
@ 2015-05-07 16:59 ` Jens Axboe
2015-05-07 21:04 ` Bruce Cran
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2015-05-07 16:59 UTC (permalink / raw)
To: Bruce Cran, fio@vger.kernel.org
On 05/06/2015 09:31 PM, Bruce Cran wrote:
> I've attached a patch that adds ctime_r to the Windows build and an
> empty ioctl.h header that the build appears to need now. There are
> linker errors after building the fio binary - I guess the other programs
> need the Windows posix.c linked in? I'm not sure how the
> configure/build system works now, so I wasn't able to update it.
Added. Side note - your email consistently ends up in my gmail spam, for
some reason...
What are the linker errors? I'm guessing you need to check and add your
OS dependencies to T_OBJS in the Makefile, when targetos is Windows.
ifeq ($(CONFIG_TARGET_OS), Linux)
T_OBJS += whatever.o
endif
or something like that.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 16:59 ` Jens Axboe
@ 2015-05-07 21:04 ` Bruce Cran
2015-05-07 21:06 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Cran @ 2015-05-07 21:04 UTC (permalink / raw)
To: Jens Axboe, fio@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
On 5/7/2015 10:59 AM, Jens Axboe wrote:
> Added. Side note - your email consistently ends up in my gmail spam,
> for some reason...
Ugh, it's because DMARC doesn't work through mailing lists without
jumping through hoops. I'll see if I can disable it for specified
destinations.
>
> What are the linker errors? I'm guessing you need to check and add
> your OS dependencies to T_OBJS in the Makefile, when targetos is Windows.
Got it - I'd forgotten that the Makefile is still checked in and it's
not generated by the configure script!
I've attached a patch which should make the build work a lot better on
Windows.
--
Bruce
[-- Attachment #2: 0001-Fix-compiler-warning-and-test-progs-linker-errors-on.patch --]
[-- Type: text/plain, Size: 1540 bytes --]
From 4a6ef95b40558b215c113a0260b891b36f376f83 Mon Sep 17 00:00:00 2001
From: Bruce Cran <bruce.cran@gmail.com>
Date: Thu, 7 May 2015 14:56:58 -0600
Subject: [PATCH] Fix compiler warning and test progs linker errors on Windows
Add prototype for ctime_r to os-windows.h to avoid compiler warning.
Link in os/windows/posix.o and lib/hweight.o to allow test progs to
build on Windows.
---
Makefile | 6 ++++++
os/os-windows.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/Makefile b/Makefile
index 1b312cb..d9aedf5 100644
--- a/Makefile
+++ b/Makefile
@@ -218,6 +218,12 @@ T_OBJS += $(T_LFSR_TEST_OBJS)
T_OBJS += $(T_BTRACE_FIO_OBJS)
T_OBJS += $(T_DEDUPE_OBJS)
+ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
+ T_DEDUPE_OBJS += os/windows/posix.o lib/hweight.o
+ T_SMALLOC_OBJS += os/windows/posix.o lib/hweight.o
+ T_LFSR_TEST_OBJS += os/windows/posix.o lib/hweight.o
+endif
+
T_TEST_PROGS = $(T_SMALLOC_PROGS)
T_TEST_PROGS += $(T_IEEE_PROGS)
T_PROGS += $(T_ZIPF_PROGS)
diff --git a/os/os-windows.h b/os/os-windows.h
index 6603635..9e931c9 100644
--- a/os/os-windows.h
+++ b/os/os-windows.h
@@ -105,6 +105,7 @@ int fcntl(int fildes, int cmd, ...);
int fdatasync(int fildes);
int lstat(const char * path, struct stat * buf);
uid_t geteuid(void);
+char* ctime_r(const time_t *t, char *buf);
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);
ssize_t pwrite(int fildes, const void *buf, size_t nbyte,
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 21:04 ` Bruce Cran
@ 2015-05-07 21:06 ` Jens Axboe
2015-05-07 21:27 ` Bruce Cran
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2015-05-07 21:06 UTC (permalink / raw)
To: Bruce Cran, fio@vger.kernel.org
On 05/07/2015 03:04 PM, Bruce Cran wrote:
> On 5/7/2015 10:59 AM, Jens Axboe wrote:
>> Added. Side note - your email consistently ends up in my gmail spam,
>> for some reason...
>
> Ugh, it's because DMARC doesn't work through mailing lists without
> jumping through hoops. I'll see if I can disable it for specified
> destinations.
This one got through, but probably because it's a reply..
>> What are the linker errors? I'm guessing you need to check and add
>> your OS dependencies to T_OBJS in the Makefile, when targetos is Windows.
>
> Got it - I'd forgotten that the Makefile is still checked in and it's
> not generated by the configure script!
> I've attached a patch which should make the build work a lot better on
> Windows.
Thanks, added.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 21:06 ` Jens Axboe
@ 2015-05-07 21:27 ` Bruce Cran
2015-05-07 21:32 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Cran @ 2015-05-07 21:27 UTC (permalink / raw)
To: Jens Axboe, fio@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
On 5/7/2015 3:06 PM, Jens Axboe wrote:
>
> Thanks, added
And another patch, since my tree wasn't quite up-to-date: this time to
add <limits.h> to eta.c and define _POSIX_HOST_NAME_MAX.
--
Bruce
[-- Attachment #2: 0001-Fix-Windows-build-add-limits.h-to-eta.c-and-define-_.patch --]
[-- Type: text/plain, Size: 980 bytes --]
From eeb938efb2d79cd53fee8cd60f6d07033e37cbf1 Mon Sep 17 00:00:00 2001
From: Bruce Cran <bruce.cran@gmail.com>
Date: Thu, 7 May 2015 15:24:45 -0600
Subject: [PATCH] Fix Windows build: add limits.h to eta.c and define
_POSIX_HOST_NAME_MAX
---
eta.c | 1 +
os/windows/posix.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/eta.c b/eta.c
index e458457..a5a8f53 100644
--- a/eta.c
+++ b/eta.c
@@ -4,6 +4,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <limits.h>
#include "fio.h"
#include "lib/pow2.h"
diff --git a/os/windows/posix.h b/os/windows/posix.h
index 85640a2..3b4865f 100644
--- a/os/windows/posix.h
+++ b/os/windows/posix.h
@@ -4,6 +4,8 @@
typedef off_t off64_t;
typedef int clockid_t;
+#define _POSIX_HOST_NAME_MAX 255
+
extern int clock_gettime(clockid_t clock_id, struct timespec *tp);
extern int inet_aton(const char *, struct in_addr *);
extern int win_to_posix_error(DWORD winerr);
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 21:27 ` Bruce Cran
@ 2015-05-07 21:32 ` Jens Axboe
2015-05-07 22:56 ` Bruce Cran
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2015-05-07 21:32 UTC (permalink / raw)
To: Bruce Cran, fio@vger.kernel.org
On 05/07/2015 03:27 PM, Bruce Cran wrote:
> On 5/7/2015 3:06 PM, Jens Axboe wrote:
>>
>> Thanks, added
>
> And another patch, since my tree wasn't quite up-to-date: this time to
> add <limits.h> to eta.c and define _POSIX_HOST_NAME_MAX.
Honestly, that should just use PATH_MAX. I'll make that change instead
of adding this patch.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add Windows ctime_r implementation and empty ioctl.h header
2015-05-07 21:32 ` Jens Axboe
@ 2015-05-07 22:56 ` Bruce Cran
2015-05-08 0:20 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Bruce Cran @ 2015-05-07 22:56 UTC (permalink / raw)
To: Jens Axboe, fio@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
On 5/7/2015 3:32 PM, Jens Axboe wrote:
> Honestly, that should just use PATH_MAX. I'll make that change instead
> of adding this patch
Thanks. And one last patch, to fix the Windows installer build this time.
--
Bruce
[-- Attachment #2: 0001-Fix-Windows-installer-build-LICENSE-is-now-MORAL-LIC.patch --]
[-- Type: text/plain, Size: 1101 bytes --]
From 452f548cd17d13e6fe0047a82204f83202ea9fbe Mon Sep 17 00:00:00 2001
From: Bruce Cran <bruce.cran@gmail.com>
Date: Thu, 7 May 2015 16:54:37 -0600
Subject: [PATCH] Fix Windows installer build: LICENSE is now MORAL-LICENSE
---
os/windows/install.wxs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/os/windows/install.wxs b/os/windows/install.wxs
index ba58b92..f392606 100755
--- a/os/windows/install.wxs
+++ b/os/windows/install.wxs
@@ -40,7 +40,7 @@
<File Id="COPYING" Name="COPYING.txt" Source="..\..\COPYING"/>
</Component>
<Component>
- <File Id="LICENSE" Name="LICENSE.txt" Source="..\..\LICENSE"/>
+ <File Id="MORAL_LICENSE" Name="MORAL-LICENSE.txt" Source="..\..\MORAL-LICENSE"/>
</Component>
<Directory Id="examples" Name="examples"/>
</Directory>
@@ -54,7 +54,7 @@
<ComponentRef Id="README"/>
<ComponentRef Id="REPORTING_BUGS"/>
<ComponentRef Id="COPYING"/>
- <ComponentRef Id="LICENSE"/>
+ <ComponentRef Id="MORAL_LICENSE"/>
<ComponentGroupRef Id="examples"/>
</Feature>
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-05-08 0:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-07 3:31 [PATCH] Add Windows ctime_r implementation and empty ioctl.h header Bruce Cran
2015-05-07 16:59 ` Jens Axboe
2015-05-07 21:04 ` Bruce Cran
2015-05-07 21:06 ` Jens Axboe
2015-05-07 21:27 ` Bruce Cran
2015-05-07 21:32 ` Jens Axboe
2015-05-07 22:56 ` Bruce Cran
2015-05-08 0:20 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox