Skip to content

Commit 45d6e16

Browse files
committed
[sync] implement aio_realpath for windows.
1 parent 7aa5d93 commit 45d6e16

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

cvs-vers

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
eio.3:1.1
22
configure.ac:1.10
3-
Changes:1.51
3+
Changes:1.52
44
aclocal.m4:1.3
55
demo.c:1.4
66
ecb.h:1.17
7+
Makefile.am:1.4
78
etp.c:1.1
89
libeio.m4:1.22
9-
Makefile.am:1.4
10-
xthread.h:1.16
10+
xthread.h:1.17
1111
eio.pod:1.34
12-
LICENSE:1.1
13-
autogen.sh:1.4
12+
eio.c:1.130
1413
eio.h:1.53
15-
eio.c:1.129
14+
autogen.sh:1.4
15+
LICENSE:1.1

src/Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ TODO: maybe work around 3.996gb barrier in pread/pwrite as well, maybe readahead
7373
- remove pread/pwrite emulation, as the only system that lacked them
7474
(cygwin) provides them for a while now.
7575
- provide pread/pwrite implementations for win32.
76+
- implement aio_realpath for windows.
7677

src/eio.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ eio__lseek (eio_req *req)
970970
static int
971971
eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
972972
{
973-
const char *rel = path;
974973
char *res;
974+
const char *rel = path;
975975
char *tmp1, *tmp2;
976976
#if SYMLOOP_MAX > 32
977977
int symlinks = SYMLOOP_MAX;
@@ -988,6 +988,23 @@ eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
988988
return -1;
989989

990990
res = tmpbuf_get (tmpbuf, PATH_MAX * 3);
991+
#ifdef _WIN32
992+
if (_access (rel, 4) != 0)
993+
return -1;
994+
995+
symlinks = GetFullPathName (rel, PATH_MAX * 3, res, 0);
996+
997+
errno = ENAMETOOLONG;
998+
if (symlinks >= PATH_MAX * 3)
999+
return -1;
1000+
1001+
errno = EIO;
1002+
if (symlinks <= 0)
1003+
return -1;
1004+
1005+
return symlinks;
1006+
1007+
#else
9911008
tmp1 = res + PATH_MAX;
9921009
tmp2 = tmp1 + PATH_MAX;
9931010

@@ -1120,6 +1137,7 @@ eio__realpath (struct tmpbuf *tmpbuf, eio_wd wd, const char *path)
11201137
*res++ = '/';
11211138

11221139
return res - (char *)tmpbuf->ptr;
1140+
#endif
11231141
}
11241142

11251143
static signed char

src/xthread.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@
1717

1818
#ifdef _WIN32
1919

20-
#define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls
21-
#define _WIN32_WINNT 0x400
20+
//#define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls, fails with mingw
21+
#define _WIN32_WINNT 0x400 // maybe working alternative for mingw
2222
#include <stdio.h>//D
2323
#include <fcntl.h>
2424
#include <io.h>
2525
#include <time.h>
2626
#include <winsock2.h>
2727
#include <process.h>
2828
#include <windows.h>
29+
30+
/* work around some bugs in ptw32 */
31+
#if defined(__MINGW32__) && defined(_TIMESPEC_DEFINED)
32+
#define HAVE_STRUCT_TIMESPEC 1
33+
#endif
34+
2935
#include <pthread.h>
3036
#define sigset_t int
3137
#define sigfillset(a)

0 commit comments

Comments
 (0)