CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+CHECK_C_SOURCE_COMPILES("#include <stdint.h>
+ int main(void) {
+ intptr_t test = 1;
+ return 0;
+ }" LWS_HAS_INTPTR_T)
+
# These don't work Cross...
#CHECK_TYPE_SIZE(pid_t PID_T_SIZE)
#CHECK_TYPE_SIZE(size_t SIZE_T_SIZE)
message(" LWS_HAVE_ATOLL = ${LWS_HAVE_ATOLL}")
message(" LWS_HAVE__ATOI64 = ${LWS_HAVE__ATOI64}")
message(" LWS_HAVE_STAT32I64 = ${LWS_HAVE_STAT32I64}")
+message(" LWS_HAS_INTPTR_T = ${LWS_HAS_INTPTR_T}")
message("---------------------------------------------------------------------")
for (n = 0; n < vh->count_protocols; n++)
if (!strcmp(pvo->value, vh->protocols[n].name)) {
((struct lws_protocol_vhost_options *)pvo)->value =
- (const char *)(long)n;
+ (const char *)(lws_intptr_t)n;
break;
}
if (n == vh->count_protocols)
while (ext && ext->callback && !handled) {
m = ext->callback(context, ext, wsi, reason,
- (void *)(long)n, arg, len);
+ (void *)(lws_intptr_t)n, arg, len);
if (m < 0) {
lwsl_ext("Ext '%s' failed to handle callback %d!\n",
wsi->active_extensions[n]->name, reason);
printf(" %s=%d/", s, sa->sa_family);
#ifdef LWS_HAVE_STRUCT_SOCKADDR_SA_LEN
for (i = 0;
- i < sa->sa_len - ((long)sa->sa_data - (long)&sa->sa_family); i++)
+ i < sa->sa_len - ((lws_intptr_t)sa->sa_data - (lws_intptr_t)&sa->sa_family); i++)
printf("%02x", ((unsigned char *)sa->sa_data)[i]);
#else
for (i = 0; i < sizeof(sa->sa_data); i++)
#else
(void)wsi;
#endif
- if ((long)(end - *p) < 3)
+ if ((lws_intptr_t)(end - *p) < 3)
return 1;
*((*p)++) = '\x0d';
*((*p)++) = '\x0a';
break;
case LWS_HTTP2_FRAME_TYPE_WINDOW_UPDATE:
wsi->u.http2.hpack_e_dep &= ~(1 << 31);
- if ((long long)swsi->u.http2.tx_credit + (unsigned long long)wsi->u.http2.hpack_e_dep > (~(1 << 31)))
+ if ((lws_intptr_t)swsi->u.http2.tx_credit + (lws_intptr_t)wsi->u.http2.hpack_e_dep > (~(1 << 31)))
return 1; /* actually need to close swsi not the whole show */
swsi->u.http2.tx_credit += wsi->u.http2.hpack_e_dep;
if (swsi->u.http2.waiting_tx_credit && swsi->u.http2.tx_credit > 0) {
static void *
lwsws_align(struct jpargs *a)
{
- if ((unsigned long)(a->p) & 15)
- a->p += 16 - ((unsigned long)(a->p) & 15);
+ if ((lws_intptr_t)(a->p) & 15)
+ a->p += 16 - ((lws_intptr_t)(a->p) & 15);
return a->p;
}
&wsi->w_read.uv_watcher, wsi->desc.sockfd);
if (n) {
lwsl_err("uv_poll_init failed %d, sockfd=%p\n",
- n, (void *)(long)wsi->desc.sockfd);
+ n, (void *)(lws_intptr_t)wsi->desc.sockfd);
return -1;
}
static void
lws_libuv_closewsi_m(uv_handle_t* handle)
{
- lws_sockfd_type sockfd = (lws_sockfd_type)(long long)handle->data;
+ lws_sockfd_type sockfd = (lws_sockfd_type)(lws_intptr_t)handle->data;
compatible_close(sockfd);
}
{
uv_handle_t *h = (void *)&wsi->w_read.uv_watcher;
- h->data = (void *)(long long)wsi->desc.sockfd;
+ h->data = (void *)(lws_intptr_t)wsi->desc.sockfd;
/* required to defer actual deletion until libuv has processed it */
uv_close((uv_handle_t*)&wsi->w_read.uv_watcher, lws_libuv_closewsi_m);
}
#include <stdarg.h>
#endif
+#if defined(LWS_HAS_INTPTR_T)
+#include <stdint.h>
+#define lws_intptr_t intptr_t
+#else
+typedef unsigned long long lws_intptr_t;
+#endif
+
#if defined(LWS_WITH_ESP8266)
struct sockaddr_in;
#define LWS_POSIX 0
if (address == INADDR_NONE)
return -1;
- addr->sin_addr.s_addr = (unsigned long)address;
+ addr->sin_addr.s_addr = (lws_intptr_t)address;
return 0;
}
lwsl_notice("%s: doing range start %llu\n", __func__, wsi->u.http.range.start);
- if ((long)lws_vfs_file_seek_cur(wsi->u.http.fop_fd,
+ if ((long long)lws_vfs_file_seek_cur(wsi->u.http.fop_fd,
wsi->u.http.range.start -
wsi->u.http.filepos) < 0)
goto file_had_it;
}
#endif
- assert(!!pt->ah_wait_list_length == !!(int)(long)pt->ah_wait_list);
+ assert(!!pt->ah_wait_list_length == !!(lws_intptr_t)pt->ah_wait_list);
bail:
lwsl_info("%s: wsi %p: ah %p (tsi=%d, count = %d)\n", __func__,
(void *)wsi, (void *)ah, wsi->tsi,
if (spin == 5)
lwsl_err("symlink loop %s \n", path);
- n = sprintf(sym, "%08lX%08lX",
- (unsigned long)lws_vfs_get_length(wsi->u.http.fop_fd),
+ n = sprintf(sym, "%08llX%08lX",
+ (unsigned long long)lws_vfs_get_length(wsi->u.http.fop_fd),
(unsigned long)lws_vfs_get_mod_time(wsi->u.http.fop_fd));
/* disable ranges if IF_RANGE token invalid */
if (n > (int)strlen(pvo->name) &&
!strcmp(&path[n - strlen(pvo->name)], pvo->name)) {
wsi->sending_chunked = 1;
- wsi->protocol_interpret_idx = (char)(long)pvo->value;
+ wsi->protocol_interpret_idx = (char)(lws_intptr_t)pvo->value;
lwsl_info("want %s interpreted by %s\n", path,
- wsi->vhost->protocols[(int)(long)(pvo->value)].name);
- wsi->protocol = &wsi->vhost->protocols[(int)(long)(pvo->value)];
+ wsi->vhost->protocols[(int)(lws_intptr_t)(pvo->value)].name);
+ wsi->protocol = &wsi->vhost->protocols[(int)(lws_intptr_t)(pvo->value)];
if (lws_ensure_user_space(wsi))
return -1;
break;
if (type & LWS_ADOPT_SOCKET) { /* socket desc */
lwsl_debug("%s: new wsi %p, sockfd %d\n", __func__, new_wsi,
- (int)(size_t)fd.sockfd);
+ (int)(lws_intptr_t)fd.sockfd);
if (type & LWS_ADOPT_HTTP)
/* the transport is accepted...
#endif
} else /* file desc */
lwsl_debug("%s: new wsi %p, filefd %d\n", __func__, new_wsi,
- (int)(size_t)fd.filefd);
+ (int)(lws_intptr_t)fd.filefd);
/*
* A new connection was accepted. Give the user a chance to
*/
if ((wsi->vhost->protocols[0].callback)(wsi,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
- NULL, (void *)(long)accept_fd, 0)) {
+ NULL, (void *)(lws_intptr_t)accept_fd, 0)) {
lwsl_debug("Callback denied network connection\n");
compatible_close(accept_fd);
break;
#cmakedefine LWS_HAVE_TLSV1_2_CLIENT_METHOD
#cmakedefine LWS_HAVE_SSL_SET_INFO_CALLBACK
+#cmakedefine LWS_HAS_INTPTR_T
+
${LWS_SIZEOFPTR_CODE}
l = 0;
while (shift >= 0) {
- l |= ((unsigned long long)*p++) << shift;
+ l |= ((lws_intptr_t)*p++) << shift;
shift -= 8;
}
void *thread_service(void *threadid)
{
- while (lws_service_tsi(context, 50, (int)(long)threadid) >= 0 && !force_exit)
+ while (lws_service_tsi(context, 50, (int)(lws_intptr_t)threadid) >= 0 && !force_exit)
;
pthread_exit(NULL);
for (n = 0; n < lws_get_count_threads(context); n++)
if (pthread_create(&pthread_service[n], NULL, thread_service,
- (void *)(long)n))
+ (void *)(lws_intptr_t)n))
lwsl_err("Failed to start service thread\n");
/* wait for all the service threads to exit */