This commit is contained in:
2018-05-16 10:10:23 +02:00
commit 79abc63edd
597 changed files with 93351 additions and 0 deletions

167
node_modules/epoll/History.md generated vendored Normal file
View File

@ -0,0 +1,167 @@
2.0.1 - Apr 02 2018
===================
* update dependencies (nan v2.10.0)
2.0.0 - Feb 25 2018
===================
* update dependencies (nan v2.9.2)
* fix deprecations
* drop support for node.js v0.10, v0.12, v5 and v7
1.0.2 - Dec 24 2017
===================
* don't suppress deprecated-declaration warnings
* nan 2.8.0
1.0.1 - Nov 04 2017
===================
* suppress deprecated-declaration warnings
* document node 9 support
1.0.0 - Oct 15 2017
===================
* update dependencies (bindings v1.3.0, nan v2.7.0)
* document supported node versions
0.1.22 - Jun 18 2017
====================
* nan 2.6.2
0.1.21 - Feb 12 2017
====================
* require node v0.10 or higher
* nan 2.5.1
0.1.20 - Jul 22 2016
====================
* document dependency on Linux
* nan 2.4.0
0.1.19 - May 03 2016
====================
* add accessor for closed property to instance template
0.1.18 - Apr 27 2016
====================
* upgrade to NAN v2.3.2 for Node.js v6.0.0 compatability
0.1.17 - Jan 29 2016
====================
* nan 2.2.0
* documentation
0.1.16 - Oct 10 2015
====================
* documentation
* nan 2.1.0
0.1.15 - Aug 24 2015
====================
* fix null passed to callback
0.1.14 - Aug 24 2015
====================
* nan2 migration
0.1.13 - May 07 2015
====================
* io.js v2.0.0+ compatibility [#13](https://github.com/fivdi/epoll/issues/13)
0.1.12 - Feb 10 2015
====================
* nan 1.6.2
* refactored interrupts-per-second example [#11](https://github.com/fivdi/epoll/issues/11)
0.1.11 - Jan 17 2015
====================
* support io.js [#10](https://github.com/fivdi/epoll/issues/10)
0.1.10 - Nov 02 2014
====================
* nan 1.4.0
0.1.9 - Aug 09 2014
===================
* nan 1.3.0
0.1.8 - Jul 12 2014
===================
* nan 1.2.0
* bindings 1.2.1
0.1.7 - May 29 2014
===================
* Fixed date in History.md
0.1.6 - May 29 2014
===================
* Replace NanSymbol with NanNew<v8:String> [#9](https://github.com/fivdi/epoll/issues/9)
0.1.5 - May 04 2014
===================
* nan 1.0.0 alignment [#8](https://github.com/fivdi/epoll/issues/8)
0.1.4 - Apr 18 2014
===================
* Documented BeagleBone Ångström prerequisites
* Use bindings for laoding
0.1.3 - Mar 23 2014
===================
* 0.11.5+ compatibility [#7](https://github.com/fivdi/epoll/issues/7)
* Updated dependencies: nan 0.6.2 -> 0.8.0
0.1.2 - Nov 21 2013
===================
* 0.11.9+ compatibility [#6](https://github.com/fivdi/epoll/issues/6)
* Updated dependencies: nan 0.5.2 -> 0.6.0
0.1.1 - Nov 19 2013
===================
* A hopefully successfull attempt to fix an npm install issue
0.1.0 - Nov 18 2013
===================
* Updated dependencies: nan 0.4.1 -> 0.5.2
* removed using namespace v8 (bad practice)
0.0.8 - Oct 14 2013
===================
* Epoll thread code improved (#4)
* EINTR handling (#3)
0.0.7 - Oct 05 2013
===================
* closed property added (#1)
* Segfault issue fixed (#5)
* add and modify now accept Epoll.EPOLLET as an event (#2)
0.0.6 - Oct 01 2013
===================
* Example for watching outputs added
* Tests improved
0.0.5 - Sep 25 2013
===================
* Link removed from readme
0.0.4 - Sep 25 2013
===================
* Url in readme fixed so that it displays correctly at npmjs.org, hopefully
0.0.3 - Sep 25 2013
===================
* Content added to readme
* Examples for the BeagleBone and RaspberryPi
* Minor bug fixes
* Tests improved
0.0.2 - Sep 22 2013
===================
* Tests extended and improved
* Allow installation on non-Linux systems but provide no functionality (needed for firmata-pi tests)
0.0.1 - Sep 22 2013
===================
* Initial release

20
node_modules/epoll/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 fivdi
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

256
node_modules/epoll/README.md generated vendored Normal file
View File

@ -0,0 +1,256 @@
# epoll
A low-level **Node.js** binding for the Linux epoll API for monitoring multiple
file descriptors to see if I/O is possible on any of them.
This module was initially written to detect EPOLLPRI events indicating that
urgent data is available for reading. EPOLLPRI events are triggered by
interrupt generating [GPIO](https://www.kernel.org/doc/Documentation/gpio/)
pins. The epoll module is used by [onoff](https://github.com/fivdi/onoff)
to detect such interrupts.
epoll supports Node.js versions 4, 6, 8 and 9.
## Installation
Note that epoll can only be installed successfully on Linux systems. Attempting
to install epoll on other systems will result in compile errors.
```
npm install epoll
```
## API
* Epoll(callback) - Constructor. The callback is called when epoll events
occur and it gets three arguments (err, fd, events).
* add(fd, events) - Register file descriptor fd for the event types specified
by events.
* remove(fd) - Deregister file descriptor fd.
* modify(fd, events) - Change the event types associated with file descriptor
fd to those specified by events.
* close() - Deregisters all file descriptors and free resources.
Event Types
* Epoll.EPOLLIN
* Epoll.EPOLLOUT
* Epoll.EPOLLRDHUP
* Epoll.EPOLLPRI
* Epoll.EPOLLERR
* Epoll.EPOLLHUP
* Epoll.EPOLLET
* Epoll.EPOLLONESHOT
Event types can be combined with | when calling add or modify. For example,
Epoll.EPOLLPRI | Epoll.EPOLLONESHOT could be passed to add to detect a single
GPIO interrupt.
## Example - Watching Buttons
The following example shows how epoll can be used to detect interrupts from a
momentary push-button connected to GPIO #4 (pin P1-7) on the Raspberry Pi.
The source code is available in the
[example directory](https://github.com/fivdi/epoll/tree/master/example/watch-button)
and can easily be modified for using a different GPIO on the Pi or a different
platform such as the BeagleBone.
The first step is to export GPIO #4 as an interrupt generating input using
the export bash script from the examples directory.
```
./export
```
export:
```bash
#!/bin/sh
echo 4 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio4/direction
echo both > /sys/class/gpio/gpio4/edge
```
Then run watch-button to be notified every time the button is pressed and
released. If there is no hardware debounce circuit for the push-button, contact
bounce issues are very likely to be visible on the console output.
watch-button terminates automatically after 30 seconds.
```
node watch-button
```
watch-button:
```js
var Epoll = require('../../build/Release/epoll').Epoll,
fs = require('fs'),
valuefd = fs.openSync('/sys/class/gpio/gpio4/value', 'r'),
buffer = new Buffer(1);
// Create a new Epoll. The callback is the interrupt handler.
var poller = new Epoll(function (err, fd, events) {
// Read GPIO value file. Reading also clears the interrupt.
fs.readSync(fd, buffer, 0, 1, 0);
console.log(buffer.toString() === '1' ? 'released' : 'pressed');
});
// Read the GPIO value file before watching to
// prevent an initial unauthentic interrupt.
fs.readSync(valuefd, buffer, 0, 1, 0);
// Start watching for interrupts.
poller.add(valuefd, Epoll.EPOLLPRI);
// Stop watching after 30 seconds.
setTimeout(function () {
poller.remove(valuefd).close();
}, 30000);
```
When watch-button has terminated, GPIO #4 can be unexported using the
unexport bash script.
```
./unexport
```
unexport:
```bash
#!/bin/sh
echo 4 > /sys/class/gpio/unexport
```
## Example - Interrupts Per Second
The following example shows how epoll can be used to determine the number of
hardware interrupts that can be handled per second on the Raspberry Pi.
The source code is available in the
[example directory](https://github.com/fivdi/epoll/tree/master/example/interrupts-per-second)
and can easily be modified to use different GPIOs on the Raspberry Pi or a
different platform such as the BeagleBone.
In this example, GPIO #7 is wired to one end of a 1kΩ current limiting
resistor and GPIO #8 is wired to the other end of the resistor. GPIO #7 is an
input and GPIO #8 is an output.
The first step is to export GPIOs #7 and #8 using the export bash script from
the examples directory.
```
./export
```
export:
```bash
#!/bin/sh
echo 7 > /sys/class/gpio/export
echo 8 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio7/direction
echo both > /sys/class/gpio/gpio7/edge
echo out > /sys/class/gpio/gpio8/direction
```
Then run interrupts-per-second. interrupts-per-second toggles the state of the
output every time it detects an interrupt on the input. Each toggle will
trigger the next interrupt. After five seconds, interrupts-per-second prints
the number of interrupts it detected per second.
```
node interrupts-per-second
```
interrupts-per-second:
```js
var Epoll = require('../../build/Release/epoll').Epoll,
fs = require('fs'),
inputfd = fs.openSync('/sys/class/gpio/gpio7/value', 'r+'),
outputfd = fs.openSync('/sys/class/gpio/gpio8/value', 'r+'),
value = new Buffer(1), // The three Buffers here are global
zero = new Buffer('0'), // to improve performance.
one = new Buffer('1'),
count = 0,
time;
// Create a new Epoll. The callback is the interrupt handler.
var poller = new Epoll(function (err, fd, events) {
var nextValue;
count++;
// Read GPIO value file. Reading also clears the interrupt.
fs.readSync(inputfd, value, 0, 1, 0);
// Toggle GPIO value. This will eventually result
// in the next interrupt being triggered.
nextValue = value[0] === zero[0] ? one : zero;
fs.writeSync(outputfd, nextValue, 0, nextValue.length, 0);
});
time = process.hrtime(); // Get start time.
// Start watching for interrupts. This will trigger the first interrupt
// as the value file already has data waiting for a read.
poller.add(inputfd, Epoll.EPOLLPRI);
// Print interrupt rate to console after 5 seconds.
setTimeout(function () {
var rate;
time = process.hrtime(time); // Get run time.
rate = Math.floor(count / (time[0] + time[1] / 1E9));
console.log(rate + ' interrupts per second');
// Stop watching.
poller.remove(inputfd).close();
}, 5000);
```
When interrupts-per-second has terminated, GPIOs #7 and #8 can be unexported
using the unexport bash script.
```
./unexport
```
unexport:
```bash
#!/bin/sh
echo 7 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport
```
Here are some results from the "Interrupts Per Second" example.
**BeagleBone, 720MHz, Ångström v2012.12, Kernel 3.8.13, epoll v0.0.6:**
Node.js | Interrupts / Second
:---: | ---:
v0.11.7 | 7152
v0.10.20 | 5861
v0.8.22 | 6098
**BeagleBone Black, 1GHz, Debian, Kernel 3.8.13, epoll v0.1.11:**
Node.js | Interrupts / Second
:---: | ---:
v0.10.25 | 9133
**Raspberry Pi, 700Mhz, Raspbian, Kernel 3.2.27+, epoll v0.0.6:**
Node.js | Interrupts / Second
:---: | ---:
v0.11.07 | 4071
v0.10.16 | 3530
v0.8.14 | 3591
**Raspberry Pi 2, 900Mhz, Raspbian, Kernel 3.18.5-v7+, epoll v0.1.11:**
Node.js | Interrupts / Second
:---: | ---:
v0.10.36 | 10438

19
node_modules/epoll/binding.gyp generated vendored Normal file
View File

@ -0,0 +1,19 @@
{
"targets": [{
"target_name": "epoll",
"conditions": [[
"OS == \"linux\"", {
"cflags": [
"-Wno-unused-local-typedefs"
]
}]
],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
],
"sources": [
"./src/epoll.cc"
]
}]
}

324
node_modules/epoll/build/Makefile generated vendored Normal file
View File

@ -0,0 +1,324 @@
# We borrow heavily from the kernel build setup, though we are simpler since
# we don't have Kconfig tweaking settings on us.
# The implicit make rules have it looking for RCS files, among other things.
# We instead explicitly write all the rules we care about.
# It's even quicker (saves ~200ms) to pass -r on the command line.
MAKEFLAGS=-r
# The source directory tree.
srcdir := ..
abs_srcdir := $(abspath $(srcdir))
# The name of the builddir.
builddir_name ?= .
# The V=1 flag on command line makes us verbosely print command lines.
ifdef V
quiet=
else
quiet=quiet_
endif
# Specify BUILDTYPE=Release on the command line for a release build.
BUILDTYPE ?= Release
# Directory all our build output goes into.
# Note that this must be two directories beneath src/ for unit tests to pass,
# as they reach into the src/ directory for data with relative paths.
builddir ?= $(builddir_name)/$(BUILDTYPE)
abs_builddir := $(abspath $(builddir))
depsdir := $(builddir)/.deps
# Object output directory.
obj := $(builddir)/obj
abs_obj := $(abspath $(obj))
# We build up a list of every single one of the targets so we can slurp in the
# generated dependency rule Makefiles in one pass.
all_deps :=
CC.target ?= $(CC)
CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
CXX.target ?= $(CXX)
CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
LINK.target ?= $(LINK)
LDFLAGS.target ?= $(LDFLAGS)
AR.target ?= $(AR)
# C++ apps need to be linked with g++.
LINK ?= $(CXX.target)
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
# to replicate this environment fallback in make as well.
CC.host ?= gcc
CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
CXX.host ?= g++
CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
LINK.host ?= $(CXX.host)
LDFLAGS.host ?=
AR.host ?= ar
# Define a dir function that can handle spaces.
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
# "leading spaces cannot appear in the text of the first argument as written.
# These characters can be put into the argument value by variable substitution."
empty :=
space := $(empty) $(empty)
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
replace_spaces = $(subst $(space),?,$1)
unreplace_spaces = $(subst ?,$(space),$1)
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
# Flags to make gcc output dependency info. Note that you need to be
# careful here to use the flags that ccache and distcc can understand.
# We write to a dep file on the side first and then rename at the end
# so we can't end up with a broken dep file.
depfile = $(depsdir)/$(call replace_spaces,$@).d
DEPFLAGS = -MMD -MF $(depfile).raw
# We have to fixup the deps output in a few ways.
# (1) the file output should mention the proper .o file.
# ccache or distcc lose the path to the target, so we convert a rule of
# the form:
# foobar.o: DEP1 DEP2
# into
# path/to/foobar.o: DEP1 DEP2
# (2) we want missing files not to cause us to fail to build.
# We want to rewrite
# foobar.o: DEP1 DEP2 \
# DEP3
# to
# DEP1:
# DEP2:
# DEP3:
# so if the files are missing, they're just considered phony rules.
# We have to do some pretty insane escaping to get those backslashes
# and dollar signs past make, the shell, and sed at the same time.
# Doesn't work with spaces, but that's fine: .d files have spaces in
# their names replaced with other characters.
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
grep -v '^$$' |\
sed -e 1d -e 's|$$|:|' \
>> $(depfile)
rm $(depfile).raw
endef
# Command definitions:
# - cmd_foo is the actual command to run;
# - quiet_cmd_foo is the brief-output summary of the command.
quiet_cmd_cc = CC($(TOOLSET)) $@
cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_cxx = CXX($(TOOLSET)) $@
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_touch = TOUCH $@
cmd_touch = touch $@
quiet_cmd_copy = COPY $@
# send stderr to /dev/null to ignore messages when linking directories.
cmd_copy = rm -rf "$@" && cp -af "$<" "$@"
quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
# Due to circular dependencies between libraries :(, we wrap the
# special "figure out circular dependencies" flags around the entire
# input list during linking.
quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
# We support two kinds of shared objects (.so):
# 1) shared_library, which is just bundling together many dependent libraries
# into a link line.
# 2) loadable_module, which is generating a module intended for dlopen().
#
# They differ only slightly:
# In the former case, we want to package all dependent code into the .so.
# In the latter case, we want to package just the API exposed by the
# outermost module.
# This means shared_library uses --whole-archive, while loadable_module doesn't.
# (Note that --whole-archive is incompatible with the --start-group used in
# normal linking.)
# Other shared-object link notes:
# - Set SONAME to the library filename so our binaries don't reference
# the local, absolute paths used on the link command-line.
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
# Define an escape_quotes function to escape single quotes.
# This allows us to handle quotes properly as long as we always use
# use single quotes and escape_quotes.
escape_quotes = $(subst ','\'',$(1))
# This comment is here just to include a ' to unconfuse syntax highlighting.
# Define an escape_vars function to escape '$' variable syntax.
# This allows us to read/write command lines with shell variables (e.g.
# $LD_LIBRARY_PATH), without triggering make substitution.
escape_vars = $(subst $$,$$$$,$(1))
# Helper that expands to a shell command to echo a string exactly as it is in
# make. This uses printf instead of echo because printf's behaviour with respect
# to escape sequences is more portable than echo's across different shells
# (e.g., dash, bash).
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
# Helper to compare the command we're about to run against the command
# we logged the last time we ran the command. Produces an empty
# string (false) when the commands match.
# Tricky point: Make has no string-equality test function.
# The kernel uses the following, but it seems like it would have false
# positives, where one string reordered its arguments.
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
# $(filter-out $(cmd_$@), $(cmd_$(1))))
# We instead substitute each for the empty string into the other, and
# say they're equal if both substitutions produce the empty string.
# .d files contain ? instead of spaces, take that into account.
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
# Helper that is non-empty when a prerequisite changes.
# Normally make does this implicitly, but we force rules to always run
# so we can check their command lines.
# $? -- new prerequisites
# $| -- order-only dependencies
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
# Helper that executes all postbuilds until one fails.
define do_postbuilds
@E=0;\
for p in $(POSTBUILDS); do\
eval $$p;\
E=$$?;\
if [ $$E -ne 0 ]; then\
break;\
fi;\
done;\
if [ $$E -ne 0 ]; then\
rm -rf "$@";\
exit $$E;\
fi
endef
# do_cmd: run a command via the above cmd_foo names, if necessary.
# Should always run for a given target to handle command-line changes.
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
# Third argument, if non-zero, makes it do POSTBUILDS processing.
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
# spaces already and dirx strips the ? characters.
define do_cmd
$(if $(or $(command_changed),$(prereq_changed)),
@$(call exact_echo, $($(quiet)cmd_$(1)))
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
$(if $(findstring flock,$(word 1,$(cmd_$1))),
@$(cmd_$(1))
@echo " $(quiet_cmd_$(1)): Finished",
@$(cmd_$(1))
)
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
@$(if $(2),$(fixup_dep))
$(if $(and $(3), $(POSTBUILDS)),
$(call do_postbuilds)
)
)
endef
# Declare the "all" target first so it is the default,
# even though we don't have the deps yet.
.PHONY: all
all:
# make looks for ways to re-generate included makefiles, but in our case, we
# don't have a direct way. Explicitly telling make that it has nothing to do
# for them makes it go faster.
%.d: ;
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
# do_cmd.
.PHONY: FORCE_DO_CMD
FORCE_DO_CMD:
TOOLSET := target
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
$(findstring $(join ^,$(prefix)),\
$(join ^,epoll.target.mk)))),)
include epoll.target.mk
endif
quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); /usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/home/wn/workspace-node/PiAlive/node_modules/epoll/build/config.gypi -I/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/wn/.node-gyp/8.11.1/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/wn/.node-gyp/8.11.1" "-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/home/wn/.node-gyp/8.11.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/wn/workspace-node/PiAlive/node_modules/epoll" "-Dnode_engine=v8" binding.gyp
Makefile: $(srcdir)/../../../../.node-gyp/8.11.1/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../../usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi
$(call do_cmd,regen_makefile)
# "all" is a concatenation of the "all" targets from all the included
# sub-makefiles. This is just here to clarify.
all:
# Add in dependency-tracking rules. $(all_deps) is the list of every single
# target in our tree. Only consider the ones with .d (dependency) info:
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
ifneq ($(d_files),)
include $(d_files)
endif

View File

@ -0,0 +1 @@
cmd_Release/epoll.node := rm -rf "Release/epoll.node" && cp -af "Release/obj.target/epoll.node" "Release/epoll.node"

View File

@ -0,0 +1 @@
cmd_Release/obj.target/epoll.node := g++ -shared -pthread -rdynamic -m64 -Wl,-soname=epoll.node -o Release/obj.target/epoll.node -Wl,--start-group Release/obj.target/epoll/src/epoll.o -Wl,--end-group

View File

@ -0,0 +1,56 @@
cmd_Release/obj.target/epoll/src/epoll.o := g++ '-DNODE_GYP_MODULE_NAME=epoll' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/home/wn/.node-gyp/8.11.1/include/node -I/home/wn/.node-gyp/8.11.1/src -I/home/wn/.node-gyp/8.11.1/deps/uv/include -I/home/wn/.node-gyp/8.11.1/deps/v8/include -I../../nan -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -Wno-unused-local-typedefs -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF ./Release/.deps/Release/obj.target/epoll/src/epoll.o.d.raw -c -o Release/obj.target/epoll/src/epoll.o ../src/epoll.cc
Release/obj.target/epoll/src/epoll.o: ../src/epoll.cc \
/home/wn/.node-gyp/8.11.1/include/node/uv.h \
/home/wn/.node-gyp/8.11.1/include/node/uv-errno.h \
/home/wn/.node-gyp/8.11.1/include/node/uv-version.h \
/home/wn/.node-gyp/8.11.1/include/node/uv-unix.h \
/home/wn/.node-gyp/8.11.1/include/node/uv-threadpool.h \
/home/wn/.node-gyp/8.11.1/include/node/uv-linux.h \
/home/wn/.node-gyp/8.11.1/include/node/v8.h \
/home/wn/.node-gyp/8.11.1/include/node/v8-version.h \
/home/wn/.node-gyp/8.11.1/include/node/v8config.h \
/home/wn/.node-gyp/8.11.1/include/node/node.h \
/home/wn/.node-gyp/8.11.1/include/node/v8.h \
/home/wn/.node-gyp/8.11.1/include/node/node_version.h \
/home/wn/.node-gyp/8.11.1/include/node/node_object_wrap.h \
/home/wn/.node-gyp/8.11.1/include/node/node_version.h ../../nan/nan.h \
/home/wn/.node-gyp/8.11.1/include/node/node_buffer.h \
/home/wn/.node-gyp/8.11.1/include/node/node.h ../../nan/nan_callbacks.h \
../../nan/nan_callbacks_12_inl.h ../../nan/nan_maybe_43_inl.h \
../../nan/nan_converters.h ../../nan/nan_converters_43_inl.h \
../../nan/nan_new.h ../../nan/nan_implementation_12_inl.h \
../../nan/nan_persistent_12_inl.h ../../nan/nan_weak.h \
../../nan/nan_object_wrap.h ../../nan/nan_private.h \
../../nan/nan_typedarray_contents.h ../../nan/nan_json.h ../src/epoll.h
../src/epoll.cc:
/home/wn/.node-gyp/8.11.1/include/node/uv.h:
/home/wn/.node-gyp/8.11.1/include/node/uv-errno.h:
/home/wn/.node-gyp/8.11.1/include/node/uv-version.h:
/home/wn/.node-gyp/8.11.1/include/node/uv-unix.h:
/home/wn/.node-gyp/8.11.1/include/node/uv-threadpool.h:
/home/wn/.node-gyp/8.11.1/include/node/uv-linux.h:
/home/wn/.node-gyp/8.11.1/include/node/v8.h:
/home/wn/.node-gyp/8.11.1/include/node/v8-version.h:
/home/wn/.node-gyp/8.11.1/include/node/v8config.h:
/home/wn/.node-gyp/8.11.1/include/node/node.h:
/home/wn/.node-gyp/8.11.1/include/node/v8.h:
/home/wn/.node-gyp/8.11.1/include/node/node_version.h:
/home/wn/.node-gyp/8.11.1/include/node/node_object_wrap.h:
/home/wn/.node-gyp/8.11.1/include/node/node_version.h:
../../nan/nan.h:
/home/wn/.node-gyp/8.11.1/include/node/node_buffer.h:
/home/wn/.node-gyp/8.11.1/include/node/node.h:
../../nan/nan_callbacks.h:
../../nan/nan_callbacks_12_inl.h:
../../nan/nan_maybe_43_inl.h:
../../nan/nan_converters.h:
../../nan/nan_converters_43_inl.h:
../../nan/nan_new.h:
../../nan/nan_implementation_12_inl.h:
../../nan/nan_persistent_12_inl.h:
../../nan/nan_weak.h:
../../nan/nan_object_wrap.h:
../../nan/nan_private.h:
../../nan/nan_typedarray_contents.h:
../../nan/nan_json.h:
../src/epoll.h:

BIN
node_modules/epoll/build/Release/epoll.node generated vendored Executable file

Binary file not shown.

BIN
node_modules/epoll/build/Release/obj.target/epoll.node generated vendored Executable file

Binary file not shown.

Binary file not shown.

6
node_modules/epoll/build/binding.Makefile generated vendored Normal file
View File

@ -0,0 +1,6 @@
# This file is generated by gyp; do not edit.
export builddir_name ?= ./build/.
.PHONY: all
all:
$(MAKE) epoll

186
node_modules/epoll/build/config.gypi generated vendored Normal file
View File

@ -0,0 +1,186 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"debug_devtools": "node",
"debug_http2": "false",
"debug_nghttp2": "false",
"force_dynamic_crt": 0,
"gas_version": "2.23",
"host_arch": "x64",
"icu_data_file": "icudt60l.dat",
"icu_data_in": "../../deps/icu-small/source/data/in/icudt60l.dat",
"icu_endianness": "l",
"icu_gyp_path": "tools/icu/icu-generic.gyp",
"icu_locales": "en,root",
"icu_path": "deps/icu-small",
"icu_small": "true",
"icu_ver_major": "60",
"llvm_version": 0,
"node_byteorder": "little",
"node_enable_d8": "false",
"node_enable_v8_vtunejit": "false",
"node_install_npm": "true",
"node_module_version": 57,
"node_no_browser_globals": "false",
"node_prefix": "/",
"node_release_urlbase": "https://nodejs.org/download/release/",
"node_shared": "false",
"node_shared_cares": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "false",
"node_shared_nghttp2": "false",
"node_shared_openssl": "false",
"node_shared_zlib": "false",
"node_tag": "",
"node_use_bundled_v8": "true",
"node_use_dtrace": "false",
"node_use_etw": "false",
"node_use_lttng": "false",
"node_use_openssl": "true",
"node_use_perfctr": "false",
"node_use_v8_platform": "true",
"node_without_node_options": "false",
"openssl_fips": "",
"openssl_no_asm": 0,
"shlib_suffix": "so.57",
"target_arch": "x64",
"uv_parent_path": "/deps/uv/",
"uv_use_dtrace": "false",
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_enable_inspector": 1,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 0,
"v8_promise_internal_field_count": 1,
"v8_random_seed": 0,
"v8_trace_maps": 0,
"v8_use_snapshot": "true",
"want_separate_host_toolset": 0,
"nodedir": "/home/wn/.node-gyp/8.11.1",
"standalone_static_library": 1,
"cache_lock_stale": "60000",
"ham_it_up": "",
"legacy_bundling": "",
"sign_git_tag": "",
"user_agent": "npm/6.0.1 node/v8.11.1 linux x64",
"always_auth": "",
"bin_links": "true",
"key": "",
"allow_same_version": "",
"description": "true",
"fetch_retries": "2",
"heading": "npm",
"if_present": "",
"init_version": "1.0.0",
"user": "",
"prefer_online": "",
"force": "",
"only": "",
"read_only": "",
"cache_min": "10",
"init_license": "ISC",
"editor": "vi",
"rollback": "true",
"tag_version_prefix": "v",
"cache_max": "Infinity",
"timing": "",
"userconfig": "/home/wn/.npmrc",
"engine_strict": "",
"init_author_name": "",
"init_author_url": "",
"tmp": "/tmp",
"depth": "Infinity",
"package_lock_only": "",
"save_dev": "",
"usage": "",
"metrics_registry": "https://registry.npmjs.org/",
"otp": "",
"package_lock": "true",
"progress": "true",
"https_proxy": "",
"save_prod": "",
"audit": "true",
"cidr": "",
"onload_script": "",
"sso_type": "oauth",
"rebuild_bundle": "true",
"save_bundle": "",
"shell": "/bin/bash",
"dry_run": "",
"prefix": "/usr",
"scope": "",
"browser": "",
"cache_lock_wait": "10000",
"ignore_prepublish": "",
"registry": "https://registry.npmjs.org/",
"save_optional": "",
"searchopts": "",
"versions": "",
"cache": "/home/wn/.npm",
"send_metrics": "",
"global_style": "",
"ignore_scripts": "",
"version": "",
"local_address": "",
"viewer": "man",
"node_gyp": "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
"prefer_offline": "",
"color": "true",
"no_proxy": "",
"fetch_retry_mintimeout": "10000",
"maxsockets": "50",
"offline": "",
"sso_poll_frequency": "500",
"umask": "0022",
"fetch_retry_maxtimeout": "60000",
"logs_max": "10",
"message": "%s",
"ca": "",
"cert": "",
"global": "",
"link": "",
"save": "true",
"access": "",
"also": "",
"unicode": "true",
"long": "",
"production": "",
"searchlimit": "20",
"unsafe_perm": "true",
"auth_type": "legacy",
"node_version": "8.11.1",
"tag": "latest",
"git_tag_version": "true",
"commit_hooks": "true",
"script_shell": "",
"shrinkwrap": "true",
"fetch_retry_factor": "10",
"save_exact": "",
"strict_ssl": "true",
"dev": "",
"globalconfig": "/usr/etc/npmrc",
"init_module": "/home/wn/.npm-init.js",
"parseable": "",
"globalignorefile": "/usr/etc/npmignore",
"cache_lock_retries": "10",
"searchstaleness": "900",
"node_options": "",
"save_prefix": "^",
"scripts_prepend_node_path": "warn-only",
"group": "1000",
"init_author_email": "",
"searchexclude": "",
"git": "git",
"optional": "true",
"json": ""
}
}

145
node_modules/epoll/build/epoll.target.mk generated vendored Normal file
View File

@ -0,0 +1,145 @@
# This file is generated by gyp; do not edit.
TOOLSET := target
TARGET := epoll
DEFS_Debug := \
'-DNODE_GYP_MODULE_NAME=epoll' \
'-DUSING_UV_SHARED=1' \
'-DUSING_V8_SHARED=1' \
'-DV8_DEPRECATION_WARNINGS=1' \
'-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DBUILDING_NODE_EXTENSION' \
'-DDEBUG' \
'-D_DEBUG' \
'-DV8_ENABLE_CHECKS'
# Flags passed to all source files.
CFLAGS_Debug := \
-fPIC \
-pthread \
-Wall \
-Wextra \
-Wno-unused-parameter \
-m64 \
-Wno-unused-local-typedefs \
-g \
-O0
# Flags passed to only C files.
CFLAGS_C_Debug :=
# Flags passed to only C++ files.
CFLAGS_CC_Debug := \
-fno-rtti \
-fno-exceptions \
-std=gnu++0x
INCS_Debug := \
-I/home/wn/.node-gyp/8.11.1/include/node \
-I/home/wn/.node-gyp/8.11.1/src \
-I/home/wn/.node-gyp/8.11.1/deps/uv/include \
-I/home/wn/.node-gyp/8.11.1/deps/v8/include \
-I$(srcdir)/../nan
DEFS_Release := \
'-DNODE_GYP_MODULE_NAME=epoll' \
'-DUSING_UV_SHARED=1' \
'-DUSING_V8_SHARED=1' \
'-DV8_DEPRECATION_WARNINGS=1' \
'-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DBUILDING_NODE_EXTENSION'
# Flags passed to all source files.
CFLAGS_Release := \
-fPIC \
-pthread \
-Wall \
-Wextra \
-Wno-unused-parameter \
-m64 \
-Wno-unused-local-typedefs \
-O3 \
-fno-omit-frame-pointer
# Flags passed to only C files.
CFLAGS_C_Release :=
# Flags passed to only C++ files.
CFLAGS_CC_Release := \
-fno-rtti \
-fno-exceptions \
-std=gnu++0x
INCS_Release := \
-I/home/wn/.node-gyp/8.11.1/include/node \
-I/home/wn/.node-gyp/8.11.1/src \
-I/home/wn/.node-gyp/8.11.1/deps/uv/include \
-I/home/wn/.node-gyp/8.11.1/deps/v8/include \
-I$(srcdir)/../nan
OBJS := \
$(obj).target/$(TARGET)/src/epoll.o
# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)
# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Debug := \
-pthread \
-rdynamic \
-m64
LDFLAGS_Release := \
-pthread \
-rdynamic \
-m64
LIBS :=
$(obj).target/epoll.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(obj).target/epoll.node: LIBS := $(LIBS)
$(obj).target/epoll.node: TOOLSET := $(TOOLSET)
$(obj).target/epoll.node: $(OBJS) FORCE_DO_CMD
$(call do_cmd,solink_module)
all_deps += $(obj).target/epoll.node
# Add target alias
.PHONY: epoll
epoll: $(builddir)/epoll.node
# Copy this to the executable output path.
$(builddir)/epoll.node: TOOLSET := $(TOOLSET)
$(builddir)/epoll.node: $(obj).target/epoll.node FORCE_DO_CMD
$(call do_cmd,copy)
all_deps += $(builddir)/epoll.node
# Short alias for building this executable.
.PHONY: epoll.node
epoll.node: $(obj).target/epoll.node $(builddir)/epoll.node
# Add executable to "all" target.
.PHONY: all
all: $(builddir)/epoll.node

2
node_modules/epoll/epoll.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
module.exports = require('bindings')('epoll.node');

7
node_modules/epoll/example/interrupts-per-second/export generated vendored Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
echo 7 > /sys/class/gpio/export
echo 8 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio7/direction
echo both > /sys/class/gpio/gpio7/edge
echo out > /sys/class/gpio/gpio8/direction

View File

@ -0,0 +1,45 @@
'use strict';
var Epoll = require('../../build/Release/epoll').Epoll,
fs = require('fs'),
inputfd = fs.openSync('/sys/class/gpio/gpio7/value', 'r+'),
outputfd = fs.openSync('/sys/class/gpio/gpio8/value', 'r+'),
value = new Buffer(1), // The three Buffers here are global
zero = new Buffer('0'), // to improve performance.
one = new Buffer('1'),
count = 0,
time;
// Create a new Epoll. The callback is the interrupt handler.
var poller = new Epoll(function (err, fd, events) {
var nextValue;
count += 1;
// Read GPIO value file. Reading also clears the interrupt.
fs.readSync(inputfd, value, 0, 1, 0);
// Toggle GPIO value. This will eventually result
// in the next interrupt being triggered.
nextValue = value[0] === zero[0] ? one : zero;
fs.writeSync(outputfd, nextValue, 0, nextValue.length, 0);
});
time = process.hrtime(); // Get start time.
// Start watching for interrupts. This will trigger the first interrupt
// as the value file already has data waiting for a read.
poller.add(inputfd, Epoll.EPOLLPRI);
// Print interrupt rate to console after 5 seconds.
setTimeout(function () {
var rate;
time = process.hrtime(time); // Get run time.
rate = Math.floor(count / (time[0] + time[1] / 1E9));
console.log(rate + ' interrupts per second');
// Stop watching.
poller.remove(inputfd).close();
}, 5000);

4
node_modules/epoll/example/interrupts-per-second/unexport generated vendored Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
echo 7 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport

5
node_modules/epoll/example/watch-button/export generated vendored Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
echo 4 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio4/direction
echo both > /sys/class/gpio/gpio4/edge

3
node_modules/epoll/example/watch-button/unexport generated vendored Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo 4 > /sys/class/gpio/unexport

View File

@ -0,0 +1,26 @@
'use strict';
var Epoll = require('../../build/Release/epoll').Epoll,
fs = require('fs'),
valuefd = fs.openSync('/sys/class/gpio/gpio4/value', 'r'),
buffer = new Buffer(1);
// Create a new Epoll. The callback is the interrupt handler.
var poller = new Epoll(function (err, fd, events) {
// Read GPIO value file. Reading also clears the interrupt.
fs.readSync(fd, buffer, 0, 1, 0);
console.log(buffer.toString() === '1' ? 'pressed' : 'released');
});
// Read the GPIO value file before watching to
// prevent an initial unauthentic interrupt.
fs.readSync(valuefd, buffer, 0, 1, 0);
// Start watching for interrupts.
poller.add(valuefd, Epoll.EPOLLPRI);
// Stop watching after 30 seconds.
setTimeout(function () {
poller.remove(valuefd).close();
}, 30000);

68
node_modules/epoll/package.json generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"_from": "epoll@^2.0.1",
"_id": "epoll@2.0.1",
"_inBundle": false,
"_integrity": "sha512-BkaCu6dpfGZqiGockN6bf0pQYUdHNjKOWflOMuYNB+JnHq+SgpBQyWE7jWOWExsGVGp99A12R16WpoBZV/0UwQ==",
"_location": "/epoll",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "epoll@^2.0.1",
"name": "epoll",
"escapedName": "epoll",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/onoff"
],
"_resolved": "https://registry.npmjs.org/epoll/-/epoll-2.0.1.tgz",
"_shasum": "4742f963048fab6ad4347f678b0e9e38d58a417e",
"_spec": "epoll@^2.0.1",
"_where": "/home/wn/workspace-node/PiAlive/node_modules/onoff",
"author": {
"name": "fivdi"
},
"bugs": {
"url": "https://github.com/fivdi/epoll/issues"
},
"bundleDependencies": false,
"dependencies": {
"bindings": "^1.3.0",
"nan": "^2.10.0"
},
"deprecated": false,
"description": "A low-level Node.js binding for the Linux epoll API",
"directories": {
"example": "example",
"test": "test"
},
"engines": {
"node": ">=4.0.0"
},
"gypfile": true,
"homepage": "https://github.com/fivdi/epoll#readme",
"keywords": [
"epoll",
"epollpri",
"poll",
"pollpri",
"gpio",
"interrupt",
"linux"
],
"license": "MIT",
"main": "epoll.js",
"name": "epoll",
"repository": {
"type": "git",
"url": "git+https://github.com/fivdi/epoll.git"
},
"scripts": {
"install": "node-gyp rebuild",
"test": "echo \"Tests can only be run manually from the command line.\" && exit 1"
},
"version": "2.0.1"
}

367
node_modules/epoll/src/epoll.cc generated vendored Normal file
View File

@ -0,0 +1,367 @@
#ifdef __linux__
#include <errno.h>
#include <pthread.h>
#include <string.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <map>
#include <list>
#include <uv.h>
#include <v8.h>
#include <node.h>
#include <node_object_wrap.h>
#include <node_version.h>
#include <nan.h>
#include "epoll.h"
// TODO - strerror isn't threadsafe, use strerror_r instead
// TODO - use uv_strerror rather than strerror_r for libuv errors?
static int epfd_g;
static uv_sem_t sem_g;
static uv_async_t async_g;
static struct epoll_event event_g;
static int errno_g;
/*
* Watcher thread
*/
static void *watcher(void *arg) {
int count;
while (true) {
// Wait till the event loop says it's ok to poll. The semaphore serves more
// than one purpose.
// - It synchronizing access to '1 element queue' in variables
// event_g and errno_g.
// - When level-triggered epoll is used, the default when EPOLLET isn't
// specified, the event triggered by the last call to epoll_wait may be
// trigged again and again if the condition that triggered it hasn't been
// cleared yet. Waiting prevents multiple triggers for the same event.
// - It forces a context switch from the watcher thread to the event loop
// thread.
uv_sem_wait(&sem_g);
do {
count = epoll_wait(epfd_g, &event_g, 1, -1);
} while (count == -1 && errno == EINTR);
errno_g = count == -1 ? errno : 0;
// Errors returned from uv_async_send are silently ignored.
uv_async_send(&async_g);
}
return 0;
}
static int start_watcher() {
static bool watcher_started = false;
pthread_t theread_id;
if (watcher_started)
return 0;
epfd_g = epoll_create1(0);
if (epfd_g == -1)
return errno;
int err = uv_sem_init(&sem_g, 1);
if (err < 0) {
close(epfd_g);
return -err;
}
err = uv_async_init(uv_default_loop(), &async_g, Epoll::HandleEvent);
if (err < 0) {
close(epfd_g);
uv_sem_destroy(&sem_g);
return -err;
}
// Prevent async_g from keeping event loop alive, for the time being.
uv_unref((uv_handle_t *) &async_g);
err = pthread_create(&theread_id, 0, watcher, 0);
if (err != 0) {
close(epfd_g);
uv_sem_destroy(&sem_g);
uv_close((uv_handle_t *) &async_g, 0);
return err;
}
watcher_started = true;
return 0;
}
/*
* Epoll
*/
Nan::Persistent<v8::Function> Epoll::constructor;
std::map<int, Epoll*> Epoll::fd2epoll;
Epoll::Epoll(Nan::Callback *callback)
: callback_(callback), closed_(false) {
};
Epoll::~Epoll() {
// v8 decides when and if destructors are called. In particular, if the
// process is about to terminate, it's highly likely that destructors will
// not be called. This is therefore not the place for calling the likes of
// uv_unref, which, in general, must be called to terminate a process
// gracefully!
Nan::HandleScope scope;
if (callback_) delete callback_;
};
NAN_MODULE_INIT(Epoll::Init) {
// Constructor
v8::Local<v8::FunctionTemplate> ctor =
Nan::New<v8::FunctionTemplate>(Epoll::New);
ctor->SetClassName(Nan::New("Epoll").ToLocalChecked());
ctor->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
Nan::SetPrototypeMethod(ctor, "add", Add);
Nan::SetPrototypeMethod(ctor, "modify", Modify);
Nan::SetPrototypeMethod(ctor, "remove", Remove);
Nan::SetPrototypeMethod(ctor, "close", Close);
v8::Local<v8::ObjectTemplate> itpl = ctor->InstanceTemplate();
Nan::SetAccessor(itpl, Nan::New<v8::String>("closed").ToLocalChecked(),
GetClosed);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLIN").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLIN), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLOUT").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLOUT), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLRDHUP").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLRDHUP), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLPRI").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLPRI), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLERR").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLERR), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLHUP").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLHUP), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLET").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLET), v8::ReadOnly);
Nan::SetTemplate(ctor, Nan::New<v8::String>("EPOLLONESHOT").ToLocalChecked(),
Nan::New<v8::Integer>(EPOLLONESHOT), v8::ReadOnly);
constructor.Reset(ctor->GetFunction());
Nan::Set(target, Nan::New<v8::String>("Epoll").ToLocalChecked(),
ctor->GetFunction());
// TODO - Is it a good idea to throw an exception here?
if (int err = start_watcher())
Nan::ThrowError(strerror(err)); // TODO - use err also
}
NAN_METHOD(Epoll::New) {
if (info.Length() < 1 || !info[0]->IsFunction())
return Nan::ThrowError("First argument to construtor must be a callback");
Nan::Callback *callback = new Nan::Callback(info[0].As<v8::Function>());
Epoll *epoll = new Epoll(callback);
epoll->Wrap(info.This());
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(Epoll::Add) {
Epoll *epoll = ObjectWrap::Unwrap<Epoll>(info.This());
if (epoll->closed_)
return Nan::ThrowError("add can't be called after calling close");
// Epoll.EPOLLET is -0x8000000 on ARM and an IsUint32 check fails so
// check for IsNumber instead.
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsNumber())
return Nan::ThrowError("incorrect arguments passed to add"
"(int fd, int events)");
int err = epoll->Add(info[0]->Int32Value(), info[1]->Int32Value());
if (err != 0)
return Nan::ThrowError(strerror(err)); // TODO - use err also
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(Epoll::Modify) {
Epoll *epoll = ObjectWrap::Unwrap<Epoll>(info.This());
if (epoll->closed_)
return Nan::ThrowError("modify can't be called after calling close");
// Epoll.EPOLLET is -0x8000000 on ARM and an IsUint32 check fails so
// check for IsNumber instead.
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsNumber())
return Nan::ThrowError("incorrect arguments passed to modify"
"(int fd, int events)");
int err = epoll->Modify(info[0]->Int32Value(), info[1]->Int32Value());
if (err != 0)
return Nan::ThrowError(strerror(err)); // TODO - use err also
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(Epoll::Remove) {
Epoll *epoll = ObjectWrap::Unwrap<Epoll>(info.This());
if (epoll->closed_)
return Nan::ThrowError("remove can't be called after calling close");
if (info.Length() < 1 || !info[0]->IsInt32())
return Nan::ThrowError("incorrect arguments passed to remove(int fd)");
int err = epoll->Remove(info[0]->Int32Value());
if (err != 0)
return Nan::ThrowError(strerror(err)); // TODO - use err also
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(Epoll::Close) {
Epoll *epoll = ObjectWrap::Unwrap<Epoll>(info.This());
if (epoll->closed_)
return Nan::ThrowError("close can't be called more than once");
int err = epoll->Close();
if (err != 0)
return Nan::ThrowError(strerror(err)); // TODO - use err also
info.GetReturnValue().SetNull();
}
NAN_GETTER(Epoll::GetClosed) {
Epoll *epoll = ObjectWrap::Unwrap<Epoll>(info.This());
info.GetReturnValue().Set(Nan::New<v8::Boolean>(epoll->closed_));
}
int Epoll::Add(int fd, uint32_t events) {
struct epoll_event event;
event.events = events;
event.data.fd = fd;
if (epoll_ctl(epfd_g, EPOLL_CTL_ADD, fd, &event) == -1)
return errno;
fd2epoll.insert(std::pair<int, Epoll*>(fd, this));
fds_.push_back(fd);
// Keep event loop alive. uv_unref called in Remove.
uv_ref((uv_handle_t *) &async_g);
// Prevent GC for this instance. Unref called in Remove.
Ref();
return 0;
}
int Epoll::Modify(int fd, uint32_t events) {
struct epoll_event event;
event.events = events;
event.data.fd = fd;
if (epoll_ctl(epfd_g, EPOLL_CTL_MOD, fd, &event) == -1)
return errno;
return 0;
}
int Epoll::Remove(int fd) {
if (epoll_ctl(epfd_g, EPOLL_CTL_DEL, fd, 0) == -1)
return errno;
fd2epoll.erase(fd);
fds_.remove(fd);
if (fd2epoll.empty())
uv_unref((uv_handle_t *) &async_g);
Unref();
return 0;
}
int Epoll::Close() {
closed_ = true;
delete callback_;
callback_ = 0;
std::list<int>::iterator it = fds_.begin();
for (; it != fds_.end(); it = fds_.begin()) {
int err = Remove(*it);
if (err != 0)
return err; // TODO - Returning here may leave things messed up.
}
return 0;
}
void Epoll::HandleEvent(uv_async_t* handle) {
// This method is executed in the event loop thread.
// By the time flow of control arrives here the original Epoll instance that
// registered interest in the event may no longer have this interest. If
// this is the case, the event will be silently ignored.
std::map<int, Epoll*>::iterator it = fd2epoll.find(event_g.data.fd);
if (it != fd2epoll.end()) {
it->second->DispatchEvent(errno_g, &event_g);
}
uv_sem_post(&sem_g);
}
void Epoll::DispatchEvent(int err, struct epoll_event *event) {
Nan::HandleScope scope;
Nan::AsyncResource resource("Epoll:DispatchEvent");
if (err) {
v8::Local<v8::Value> args[1] = {
v8::Exception::Error(
Nan::New<v8::String>(strerror(err)).ToLocalChecked()
)
};
callback_->Call(1, args, &resource);
} else {
v8::Local<v8::Value> args[3] = {
Nan::Null(),
Nan::New<v8::Integer>(event->data.fd),
Nan::New<v8::Integer>(event->events)
};
callback_->Call(3, args, &resource);
}
}
NODE_MODULE(epoll, Epoll::Init)
#endif

35
node_modules/epoll/src/epoll.h generated vendored Normal file
View File

@ -0,0 +1,35 @@
#ifndef EPOLL_H
#define EPOLL_H
class Epoll : public Nan::ObjectWrap {
public:
static NAN_MODULE_INIT(Init);
static void HandleEvent(uv_async_t* handle);
private:
Epoll(Nan::Callback *callback);
~Epoll();
static NAN_METHOD(New);
static NAN_METHOD(Add);
static NAN_METHOD(Modify);
static NAN_METHOD(Remove);
static NAN_METHOD(Close);
static NAN_GETTER(GetClosed);
int Add(int fd, uint32_t events);
int Modify(int fd, uint32_t events);
int Remove(int fd);
int Close();
void DispatchEvent(int err, struct epoll_event *event);
Nan::Callback *callback_;
std::list<int> fds_;
bool closed_;
static Nan::Persistent<v8::Function> constructor;
static std::map<int, Epoll*> fd2epoll;
};
#endif

37
node_modules/epoll/test/brute-force-leak-check.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
'use strict';
/*
* Create 1e9 epoll instances and use each of them to detect a single event.
* The goal here is ensure that memory usage doesn't constantly increase over
* time.
*
* This test expects a newline as input on stdin. It polls for events on stdin
* but doesn't read stdin until it has been notified about the availability of
* input data 1e9 times.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
count = 0,
stdin = 0; // fd for stdin
function once() {
var epoll = new Epoll(function (err, fd, events) {
epoll.remove(fd).close();
count += 1;
if (count % 1e5 === 0) {
console.log(' ' + count + ' instances created and events detected ');
}
if (count < 1e9) {
once();
} else {
util.read(fd); // read stdin (the newline)
}
});
epoll.add(stdin, Epoll.EPOLLIN);
}
once();

25
node_modules/epoll/test/closed.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
'use strict';
/*
*
*/
var Epoll = require('../build/Release/epoll').Epoll,
assert = require('assert'),
poller = new Epoll(function () {}),
stdin = 0;
assert(poller.closed === false);
function closePoller() {
if (!poller.closed) {
poller.remove(stdin).close();
}
}
poller.add(stdin, Epoll.EPOLLIN);
closePoller();
closePoller();
assert(poller.closed === true);

15
node_modules/epoll/test/do-almost-nothing.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
'use strict';
/*
* Make sure the process terminates when epoll is used and 'almsost nothing'
* is actually done. The epoll addon calls uv_ref and uv_unref to keep nodes
* event loop alive. Here we make sure that the addon isn't keeping the event
* loop alive unnecessarily long. If the process terminates, everything is ok.
* If it hangs, there is a problem.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll = new Epoll(function () {}),
stdin = 0; // fd for stdin
epoll.add(stdin, Epoll.EPOLLIN).remove(stdin).close();

13
node_modules/epoll/test/do-nothing.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
'use strict';
/*
* Make sure the process terminates when epoll is used and 'nothing' is
* actually done. The epoll addon calls uv_ref and uv_unref to keep nodes
* event loop alive. Here we make sure that the addon isn't keeping the event
* loop alive unnecessarily long. If the process terminates, everything is ok.
* If it hangs, there is a problem.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll0 = new Epoll(function () {}),
epoll1 = new Epoll(function () {});

29
node_modules/epoll/test/no-gc-allowed.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
'use strict';
/*
* This test resulted in a segmentation fault in epoll v0.0.6. See issue #5.
*
* There were Ref/Unref issues in the epoll addon which resulted in epoll
* instances being garbage collected while still in use.
*
* This test expects a newline as input on stdin. It should be piped in for
* for best results:
* echo | node no-gc-allowed
*/
var Epoll = require('../build/Release/epoll').Epoll;
var time = process.hrtime();
var stdin = 0; // fd for stdin
var poller = new Epoll(function () {
var timeSoFar = process.hrtime(time);
if (timeSoFar[0] > 5) {
// BB faults in ~2.5s, Pi faults in ~?s, so wait about 5s.
// In order for the segfault to occur, V8 can't have anymore required
// references to poller. If process.exit(0) is replaced with
// poller.remove(0).close(), there will be a required reference, poller
// won't be garbage collected, and there will be no segfault.
process.exit(0);
}
});
poller.add(stdin, Epoll.EPOLLIN);

28
node_modules/epoll/test/one-shot.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
'use strict';
/*
* Make sure a single EPOLLONESHOT event can be handled.
*
* This test expects a newline as input on stdin.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
eventCount = 0,
epoll,
stdin = 0; // fd for stdin
epoll = new Epoll(function (err, fd, events) {
eventCount += 1;
if (eventCount === 1) {
setTimeout(function () {
util.read(fd); // read stdin (the newline)
epoll.remove(fd).close();
}, 100);
} else {
console.log('*** Error: unexpected event');
}
});
epoll.add(stdin, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);

39
node_modules/epoll/test/performance-check.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict';
/*
* Determine approximately how many EPOLLIN events can be handled per second.
*
* This test expects a newline as input on stdin. It polls for events on stdin
* but doesn't read stdin until the test has completed. This results in a
* continuous stream of events while the test is running.
*
* Note that the rate determined is misleading as epoll is notifying us about
* the same newline all the time.
*
* The newline should be piped in for reasonable results:
* echo | node performance-check
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
time,
count = 0,
stdin = 0; // fd for stdin
var epoll = new Epoll(function (err, fd, events) {
count += 1;
});
setTimeout(function () {
var rate;
time = process.hrtime(time);
rate = Math.floor(count / (time[0] + time[1] / 1E9));
console.log(' ' + rate + ' events per second');
epoll.remove(stdin).close();
util.read(stdin); // read stdin (the newline)
}, 100);
epoll.add(stdin, Epoll.EPOLLIN);
time = process.hrtime();

38
node_modules/epoll/test/run-tests generated vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
echo 'started - do-nothing'
node do-nothing
echo 'finished - do-nothing'
echo 'started - do-almost-nothing'
node do-almost-nothing
echo 'finished - do-almost-nothing'
echo 'started - verify-events'
node verify-events
echo 'finished - verify-events'
echo 'started - closed'
node closed
echo 'finished - closed'
echo 'started - one-shot'
echo | node one-shot
echo 'finished - one-shot'
echo 'started - two-shot'
echo | node two-shot
echo 'finished - two-shot'
# brute-force-leak-check takes a while to execute so its only run occasionally
#echo 'started - brute-force-leak-check'
#echo | node brute-force-leak-check
#echo 'finished - brute-force-leak-check'
echo 'started - performance-check'
echo | node performance-check
echo 'finished - performance-check'
echo 'started - no-gc-allowed'
echo | node no-gc-allowed
echo 'finished - no-gc-allowed'

32
node_modules/epoll/test/two-shot.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
'use strict';
/*
* Make sure two EPOLLONESHOT events can be handled.
*
* This test expects a newline as input on stdin.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
eventCount = 0,
epoll,
stdin = 0; // fd for stdin
epoll = new Epoll(function (err, fd, events) {
eventCount += 1;
if (eventCount === 1) {
setTimeout(function () {
epoll.modify(fd, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);
}, 100);
} else if (eventCount === 2) {
setTimeout(function () {
util.read(fd); // read stdin (the newline)
epoll.remove(fd).close();
}, 100);
} else {
console.log('*** Error: unexpected event');
}
});
epoll.add(stdin, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);

11
node_modules/epoll/test/util.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
'use strict';
var fs = require('fs');
module.exports = {
read: function (fd) {
var buf = new Buffer(1024);
fs.readSync(fd, buf, 0, buf.length, null);
}
};

33
node_modules/epoll/test/verify-events.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
'use strict';
/*
* Verify that add and modify accept all valid event types. See issue #2.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll = new Epoll(function () {}),
stdin = 0; // fd for stdin
try {
epoll.add(stdin, Epoll.EPOLLIN).remove(stdin)
.add(stdin, Epoll.EPOLLOUT).remove(stdin)
.add(stdin, Epoll.EPOLLRDHUP).remove(stdin)
.add(stdin, Epoll.EPOLLPRI).remove(stdin)
.add(stdin, Epoll.EPOLLERR).remove(stdin)
.add(stdin, Epoll.EPOLLHUP).remove(stdin)
.add(stdin, Epoll.EPOLLET).remove(stdin)
.add(stdin, Epoll.EPOLLONESHOT)
.modify(stdin, Epoll.EPOLLIN)
.modify(stdin, Epoll.EPOLLOUT)
.modify(stdin, Epoll.EPOLLRDHUP)
.modify(stdin, Epoll.EPOLLPRI)
.modify(stdin, Epoll.EPOLLERR)
.modify(stdin, Epoll.EPOLLHUP)
.modify(stdin, Epoll.EPOLLET)
.modify(stdin, Epoll.EPOLLONESHOT)
.remove(stdin);
} catch (ex) {
console.log('*** Error: ' + ex.message);
} finally {
epoll.close();
}