Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix code to run under win32 #4

Merged
merged 1 commit into from

2 participants

@pijyoi

issues:
fmq_hash_update() asserts non-alignment failure on win32/x86 as sizeof(fmq_chunk_t) is 12 bytes.

other than that, fmq_selftest runs without assertions.

@hintjens hintjens merged commit d8417bb into zeromq:master
@hintjens
Owner

Thanks for the fix! If you have an MSVC project, you could add that to the code too.

@pijyoi
@hintjens
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 11, 2012
  1. @pijyoi
This page is out of date. Refresh to see the latest.
View
2  src/filemq.c
@@ -56,7 +56,7 @@ int main (int argc, char *argv [])
fmq_client_subscribe (client, "/");
while (!zctx_interrupted)
- sleep (1);
+ zclock_sleep (1000);
puts ("interrupted");
fmq_server_destroy (&server);
View
2  src/fmq_client.c
@@ -847,7 +847,7 @@ fmq_client_test (bool verbose)
assert (self);
fmq_client_configure (self, "client_test.cfg");
fmq_client_connect (self, "tcp://localhost:6001");
- sleep (1);
+ zclock_sleep (1000);
fmq_client_destroy (&self);
printf ("OK\n");
View
7 src/fmq_dir.c
@@ -118,17 +118,18 @@ fmq_dir_new (const char *path, const char *parent)
self->path [strlen (self->path) - 1] = 0;
// Win32 wants a wildcard at the end of the path
- char wildcard = malloc (strlen (self->path + 2));
- sprintf (wildcard, "%s//", self->path);
+ char *wildcard = malloc (strlen (self->path) + 3);
+ sprintf (wildcard, "%s/*", self->path);
WIN32_FIND_DATA entry;
HANDLE handle = FindFirstFile (wildcard, &entry);
free (wildcard);
if (handle != INVALID_HANDLE_VALUE) {
// We have read an entry, so return those values
- win_populate_entry (self, entry);
+ s_win32_populate_entry (self, &entry);
while (FindNextFile (handle, &entry))
s_win32_populate_entry (self, &entry);
+ FindClose (handle);
}
#else
// Remove any trailing slash
View
12 src/fmq_file.c
@@ -187,7 +187,12 @@ fmq_file_restat (fmq_file_t *self)
self->mode = stat_buf.st_mode;
#endif
// File is 'stable' if more than 1 second old
+#if (defined (WIN32))
+#define EPOCH_DIFFERENCE 11644473600LL
+ long age = (long) (zclock_time () - EPOCH_DIFFERENCE * 1000 - (self->time * 1000));
+#else
long age = (long) (zclock_time () - (self->time * 1000));
+#endif
self->stable = age > 1000;
}
else
@@ -278,10 +283,10 @@ s_assert_path (fmq_file_t *self)
if (slash)
*slash = 0; // Cut at slash
mode_t mode = s_file_mode (path);
- if (mode == -1) {
+ if (mode == (mode_t)-1) {
// Does not exist, try to create it
#if (defined (WIN32))
- if (CreateDirectory (path, NULL))
+ if (!CreateDirectory (path, NULL))
#else
if (mkdir (path, 0775))
#endif
@@ -516,7 +521,8 @@ fmq_file_test (bool verbose)
assert (fmq_chunk_size (chunk) == 1000100);
fmq_chunk_destroy (&chunk);
fmq_file_destroy (&link);
-
+ fmq_file_close (file); // win32 can't delete open files
+
// Remove file and directory
fmq_dir_t *dir = fmq_dir_new ("./this", NULL);
assert (fmq_dir_size (dir) == 2000200);
View
2  src/fmq_selftest.c
@@ -61,7 +61,7 @@ int main (int argc, char *argv [])
// We do this last
fmq_server_bind (server, "tcp://*:5670");
while (!zctx_interrupted)
- sleep (1);
+ zclock_sleep (1000);
fmq_server_destroy (&server);
}
else
Something went wrong with that request. Please try again.