Commit Graph

43 Commits

Author SHA1 Message Date
Bert Belder
44ecaa7c98 windows/timer: fix uv_hrtime discontinuity
Large performance counter frequency values would cause overflows, even
when 64-bit integers were used to do the multiplication with NANOSEC.
Fix this by using floating point math instead.

Fixes #850
2013-11-29 21:38:53 -08:00
Brian White
e3a657c662 unix, windows: add MAC to uv_interface_addresses()
Make uv_interface_addresses() return the MAC address as a 48 bits
binary value in the phys_addr field of the uv_interface_address_t
struct.
2013-07-25 13:49:39 +02:00
Ben Noordhuis
977e8337ba build: add mingw makefile
* add a very simple Makefile.mingw that builds libuv.a
* apply a couple of fixes to src/win so it actually builds with mingw
  (mostly missing includes)

Fixes #847.
2013-07-25 02:13:28 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Ben Noordhuis
b1d390eb79 windows: don't use uppercase in include filename
Change <Winsock2.h> to <winsock2.h>. The former breaks
cross-compilation with mingw.
2013-06-14 00:45:03 +02:00
Bert Belder
db1a8b85d2 Merge branch 'v0.10' 2013-04-10 17:53:10 +02:00
Bert Belder
1d5c61a8b3 windows: simplify netmask detection in uv_interface_addresses 2013-04-10 17:33:37 +02:00
Bert Belder
a9bce29f0c win: refactor uv_cpu_info
Fixes a couple of error handling issues:

* Don't free an uninitialized pointer when allocating memory for
  `cpu_infos` fails.
* Don't return a bogus error value when NtQuerySystemInformation fails.
  That function returns an NTSTATUS code instead of setting the last
  error.
* Don't clobber out parameters when an error happens.
2013-04-10 16:04:15 +02:00
Ben Kelly
14aa6153be unix, win: add netmask to uv_interface_address
Include the netmask when returning information about the OS network
interfaces.

This commit provides implementations for windows and those unix
platforms using getifaddrs().

AIX was not implemented because it requires the use of ioctls and I do
not have an AIX development/test environment.  The windows code was
developed using mingw on winxp as I do not have access to visual studio.

Tested on darwin (ipv4/ipv6) and winxp (ipv4 only).  Needs testing on
newer windows using ipv6 and other unix platforms.
2013-04-10 14:48:23 +02:00
Bert Belder
2e4488f35a windows: improve / fix uv_interface_addresses
* If GetAdaptersAddresses() failed, it would return UV_OK nonetheless,
  but the `adresses` and `count` out parameters would not be set.

* When adapters were enabled or added in between the two
  GetAdaptersAddresses() calls, it would fail.

* In case of an out of memory situation, libuv would crash with a fatal
  error.

* All interface information is now stored in a single heap-allocated
  area.
2012-12-04 14:04:37 +01:00
Bert Belder
7c3ba514e7 windows: use WCHAR consistently 2012-08-13 22:31:48 +02:00
Bert Belder
ea3e2cd480 windows: get rid of overly complicated uv_filetime_to_time_t helper 2012-06-22 01:45:19 +02:00
George Yohng
fbe99743d5 windows: uv_interface_addresses() should not report disconnected adapters 2012-06-09 22:38:15 +02:00
saghul
6a47e3ac7c windows: add missing include for limits.h 2012-06-09 02:51:18 +02:00
Bert Belder
24f8a53f4c windows: refactor uv_chdir implementation 2012-06-05 18:23:07 +02:00
Bert Belder
a0d2af0fd2 windows: detect when GetCurrentDirectoryW returns more than MAX_PATH chars
This should never happen. However the CRT has a code path to deal
with this situation, so at least detect it when it happens and return
an error, instead of potentially opening a security hole.
2012-06-05 18:23:06 +02:00
Bert Belder
1b75d36bab windows: refactor uv_exepath implementation 2012-06-05 00:58:50 +02:00
Bert Belder
c9f83e524c windows: refactor uv_cwd implementation 2012-06-05 00:58:49 +02:00
Bert Belder
d21fc6c333 windows: move uv_hrtime() to util.c
* It has nothing to do with timer handles, so it doesn't belong in
  timer.c
* uv_hrtime_init() was merged into uv__util_init()
2012-06-02 20:37:08 +02:00
Bert Belder
ec95a07d00 windows/util: move initialization code to uv__util_init 2012-06-02 20:35:14 +02:00
Bert Belder
1d64a36caa windows: add support for cpu times to uv_cpu_info()
* Also cleans up the code and makes it use unicode APIs consistently.
* Credits go to Brian White for creating an earlier version of this
  patch.

Closes #327
2012-06-02 20:05:12 +02:00
Ben Noordhuis
9efa8b3571 unix, windows: rework reference counting scheme
This commit changes how the event loop determines if it needs to stay alive.

Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.

While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.

That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:

 * timers: ticking
 * sockets: reading, writing or listening
 * processes: always active (for now, subject to change)
 * idle, check, prepare: only active when started

This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.

The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Bert Belder
9984d157ff Windows: make uv_uptime() more robust 2012-04-12 17:36:42 +02:00
Bert Belder
fa21584878 Whitespace 2012-04-12 03:17:03 +02:00
Brian White
442aa1f469 win: use performance counter instead of GetTickCount for uptime 2012-04-01 21:15:38 +02:00
Bert Belder
18b37d4a49 Windows: fix compiler warnings 2012-03-09 17:04:26 +01:00
Bert Belder
2ef5798c6f Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	src/unix/core.c
2012-03-08 03:22:10 +01:00
Igor Zinkovsky
9a5c1bad90 windows: fix time conversion in stat 2012-02-27 13:11:09 -08:00
Igor Zinkovsky
855764406e windows: improve uv_fs_stat performance (by about 60%) 2012-01-11 19:21:47 -08:00
Yuki Okumura
f71f5a02e6 Win: lower case tlhelp32.h to support cross compilation 2011-12-01 22:42:35 +01:00
Igor Zinkovsky
dceb3e65ca uv_cwd + uv_chdir 2011-12-01 12:27:12 -08:00
Ben Noordhuis
d396799210 Change return type of uv_get_*_memory() functions
... from double to uint64_t. Limit use of floating point in public API as much
as possible.
2011-10-21 10:09:59 -07:00
Igor Zinkovsky
81c4043c83 ipc on windows 2011-10-06 10:17:42 -07:00
Fedor Indutny
a35591bbfc os: implement loadavg (not working on cygwin/win) 2011-10-04 18:15:14 +02:00
Fedor Indutny
33cb8775bc os: implement memory bindings
* us_get_free_memory
* us_get_total_memory
2011-10-04 18:10:35 +02:00
Erick Tryzelaar
23796d208c Fixes #76. Unify OS error reporting
As a nice fringe benefit, this also shaves a word
off of a windows TCP handle by replacing "uv_err_t
bind_error" with "int bind_error".
2011-09-27 19:05:33 -07:00
Igor Zinkovsky
52511b9ddc windows: implement uv_loop_new+uv_loop_delete 2012-01-16 17:07:49 -08:00
Ben Noordhuis
71f6c0edb8 Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	src/win/util.c
2012-01-16 18:07:49 +01:00
Igor Zinkovsky
7aacfad447 windows: support for getting multiple addresses for a network interface 2011-12-14 22:56:53 -08:00
Igor Zinkovsky
3d189de699 platform api 2011-12-14 17:50:36 -08:00
Bert Belder
78debf9f67 win: multiplicity 2011-08-31 04:19:16 +02:00
Igor Zinkovsky
d272a2183d Windows: spawn child processes 2011-07-29 19:02:51 -07:00
Bert Belder
3a91232f66 Split up uv-win.c 2011-07-19 03:47:30 +02:00