mingw: updates

This commit is contained in:
Andy Green 2017-04-28 07:51:34 +08:00
parent 2238857ea4
commit 786e6dbf35
6 changed files with 24 additions and 16 deletions

View file

@ -176,7 +176,7 @@ cmake from scratch.
2. Fix up MinGW headers 2. Fix up MinGW headers
a) Add the following lines to C:\MinGW\include\winsock2.h: a) (32-bit) Add the following lines to C:\MinGW\include\winsock2.h:
``` ```
#if(_WIN32_WINNT >= 0x0600) #if(_WIN32_WINNT >= 0x0600)
@ -192,9 +192,17 @@ cmake from scratch.
#endif // (_WIN32_WINNT >= 0x0600) #endif // (_WIN32_WINNT >= 0x0600)
``` ```
(64 bit) Update crtdefs.h line 47 to say:
```
typedef __int64 ssize_t;
```
b) Create C:\MinGW\include\mstcpip.h and copy and paste the content from following link into it: b) Create C:\MinGW\include\mstcpip.h and copy and paste the content from following link into it:
http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html (32-bit) http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html
(64-bit) https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/mstcpip.h
3. Install CMake 2.6 or greater: http://cmake.org/cmake/resources/software.html 3. Install CMake 2.6 or greater: http://cmake.org/cmake/resources/software.html

View file

@ -331,7 +331,7 @@ lws_libuv_accept(struct lws *wsi, lws_sock_file_fd_type desc)
wsi->w_read.context = context; wsi->w_read.context = context;
if (wsi->mode == LWSCM_RAW_FILEDESC) if (wsi->mode == LWSCM_RAW_FILEDESC)
uv_poll_init(pt->io_loop_uv, &wsi->w_read.uv_watcher, uv_poll_init(pt->io_loop_uv, &wsi->w_read.uv_watcher,
desc.filefd); (int)desc.filefd);
else else
uv_poll_init_socket(pt->io_loop_uv, &wsi->w_read.uv_watcher, uv_poll_init_socket(pt->io_loop_uv, &wsi->w_read.uv_watcher,
desc.sockfd); desc.sockfd);
@ -571,7 +571,7 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d)
goto bail; goto bail;
} }
/* we could open it, can we get his init function? */ /* we could open it, can we get his init function? */
#if !defined(WIN32) #if !defined(WIN32) || defined(__MINGW32__)
m = lws_snprintf(path, sizeof(path) - 1, "init_%s", m = lws_snprintf(path, sizeof(path) - 1, "init_%s",
dent.name + 3 /* snip lib... */); dent.name + 3 /* snip lib... */);
path[m - 3] = '\0'; /* snip the .so */ path[m - 3] = '\0'; /* snip the .so */
@ -582,7 +582,7 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d)
#endif #endif
if (uv_dlsym(&lib, path, &v)) { if (uv_dlsym(&lib, path, &v)) {
uv_dlerror(&lib); uv_dlerror(&lib);
lwsl_err("Failed to get init on %s: %s", lwsl_err("Failed to get %s on %s: %s", path,
dent.name, lib.errmsg); dent.name, lib.errmsg);
goto bail; goto bail;
} }
@ -641,7 +641,7 @@ lws_plat_plugins_destroy(struct lws_context *context)
while (plugin) { while (plugin) {
p = plugin; p = plugin;
#if !defined(WIN32) #if !defined(WIN32) || defined(__MINGW32__)
m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + 3); m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + 3);
path[m - 3] = '\0'; path[m - 3] = '\0';
#else #else
@ -651,7 +651,7 @@ lws_plat_plugins_destroy(struct lws_context *context)
if (uv_dlsym(&plugin->lib, path, &v)) { if (uv_dlsym(&plugin->lib, path, &v)) {
uv_dlerror(&plugin->lib); uv_dlerror(&plugin->lib);
lwsl_err("Failed to get init on %s: %s", lwsl_err("Failed to get %s on %s: %s", path,
plugin->name, plugin->lib.errmsg); plugin->name, plugin->lib.errmsg);
} else { } else {
func = (lws_plugin_destroy_func)v; func = (lws_plugin_destroy_func)v;

View file

@ -223,7 +223,7 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
} }
#ifndef _WIN32
/* /*
* We leave our original process up permanently, because that * We leave our original process up permanently, because that
* suits systemd. * suits systemd.
@ -267,7 +267,7 @@ int main(int argc, char **argv)
// !!! implemenation needed // !!! implemenation needed
#endif #endif
} }
#endif
/* child process */ /* child process */
#ifndef _WIN32 #ifndef _WIN32

View file

@ -95,7 +95,7 @@ uv_timeout_cb_server_status(uv_timer_t *w
l -= n; l -= n;
} }
fd = open(fp->filepath, LWS_O_RDONLY); fd = open(fp->filepath, LWS_O_RDONLY);
if (fd != LWS_INVALID_FILE) { if (fd >= 0) {
n = read(fd, contents, sizeof(contents) - 1); n = read(fd, contents, sizeof(contents) - 1);
if (n >= 0) { if (n >= 0) {
contents[n] = '\0'; contents[n] = '\0';

View file

@ -74,7 +74,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
* simple demo use a fixed name so we don't have to deal with * simple demo use a fixed name so we don't have to deal with
* attacks */ * attacks */
#if !defined(LWS_WITH_ESP8266) #if !defined(LWS_WITH_ESP8266)
pss->fd = open("/tmp/post-file", pss->fd = (lws_filefd_type)open("/tmp/post-file",
O_CREAT | O_TRUNC | O_RDWR, 0600); O_CREAT | O_TRUNC | O_RDWR, 0600);
#endif #endif
break; break;
@ -88,7 +88,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
return 1; return 1;
#if !defined(LWS_WITH_ESP8266) #if !defined(LWS_WITH_ESP8266)
n = write(pss->fd, buf, len); n = write((int)pss->fd, buf, len);
lwsl_notice("%s: write %d says %d\n", __func__, len, n); lwsl_notice("%s: write %d says %d\n", __func__, len, n);
#else #else
lwsl_notice("%s: Received chunk size %d\n", __func__, len); lwsl_notice("%s: Received chunk size %d\n", __func__, len);
@ -97,7 +97,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
if (state == LWS_UFS_CONTENT) if (state == LWS_UFS_CONTENT)
break; break;
#if !defined(LWS_WITH_ESP8266) #if !defined(LWS_WITH_ESP8266)
close(pss->fd); close((int)pss->fd);
pss->fd = LWS_INVALID_FILE; pss->fd = LWS_INVALID_FILE;
#endif #endif
break; break;

View file

@ -147,7 +147,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
/* we get the original filename in @filename arg, but for /* we get the original filename in @filename arg, but for
* simple demo use a fixed name so we don't have to deal with * simple demo use a fixed name so we don't have to deal with
* attacks */ * attacks */
pss->post_fd = open("/tmp/post-file", pss->post_fd = (lws_filefd_type)open("/tmp/post-file",
O_CREAT | O_TRUNC | O_RDWR, 0600); O_CREAT | O_TRUNC | O_RDWR, 0600);
break; break;
case LWS_UFS_FINAL_CONTENT: case LWS_UFS_FINAL_CONTENT:
@ -159,12 +159,12 @@ file_upload_cb(void *data, const char *name, const char *filename,
if (pss->file_length > 100000) if (pss->file_length > 100000)
return 1; return 1;
n = write(pss->post_fd, buf, len); n = write((int)pss->post_fd, buf, len);
lwsl_notice("%s: write %d says %d\n", __func__, len, n); lwsl_notice("%s: write %d says %d\n", __func__, len, n);
} }
if (state == LWS_UFS_CONTENT) if (state == LWS_UFS_CONTENT)
break; break;
close(pss->post_fd); close((int)pss->post_fd);
pss->post_fd = LWS_INVALID_FILE; pss->post_fd = LWS_INVALID_FILE;
break; break;
} }