diff --git a/etc/advio.conf b/etc/advio.conf
index 9c29110e8..ddf0eab51 100644
--- a/etc/advio.conf
+++ b/etc/advio.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/eric-lab.conf b/etc/eric-lab.conf
index 019c9aedf..e5d25105f 100644
--- a/etc/eric-lab.conf
+++ b/etc/eric-lab.conf
@@ -18,7 +18,7 @@ stats = 3; # The interval in seconds to print path statistics.
name = "villas-acs" # The name of this VILLASnode. Might by used by node-types
# to identify themselves (default is the hostname).
-
+
log = {
level = 5; # The level of verbosity for debug messages
# Higher number => increased verbosity
@@ -46,7 +46,7 @@ nodes = {
{ label = "Sine" },
{ label = "Rect" },
{ label = "Ramp" }
- )
+ )
},
socket1 = {
type = "socket",
diff --git a/etc/example.conf b/etc/example.conf
index 10a5de535..0ad8845f2 100644
--- a/etc/example.conf
+++ b/etc/example.conf
@@ -18,12 +18,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -39,7 +39,7 @@ nodes = {
udp_node = { # The dictionary is indexed by the name of the node.
type = "socket", # Type can be one of: socket, opal, file, gtfpga, ngsi
# Start the server without arguments for a list of supported node types.
-
+
### The following settings are specific to the socket node-type!! ###
layer = "udp", # Layer can be one of:
@@ -57,15 +57,15 @@ nodes = {
endian = "network", # Endianess of header and data:
# big | network Use big endianess. Also know as network byte order (default)
# little Use little endianess.
-
+
local = "127.0.0.1:12001", # This node only received messages on this IP:Port pair
remote = "127.0.0.1:12000" # This node sents outgoing messages to this IP:Port pair
-
+
vectorize = 30 # Receive and sent 30 samples per message (combining).
},
ethernet_node = {
type = "socket", # See above.
-
+
### The following settings are specific to the socket node-type!! ###
layer = "eth",
@@ -87,7 +87,7 @@ nodes = {
},
opal_node = { # The server can be started as an Asynchronous process
type = "opal", # from within an OPAL-RT model.
-
+
### The following settings are specific to the opal node-type!! ###
send_id = 1, # It's possible to have multiple send / recv Icons per model
@@ -96,13 +96,13 @@ nodes = {
},
file_node = {
type = "file",
-
+
### The following settings are specific to the file node-type!! ###
in = {
uri = "logs/input.log", # These options specify the path prefix where the the files are stored
mode = "r", # The mode in which files should be opened (see open(2))
-
+
epoch_mode = "direct" # One of: direct (default), wait, relative, absolute
epoch = 10 # The interpretation of this value depends on epoch_mode (default is 0).
# Consult the documentation of a full explanation
@@ -118,24 +118,24 @@ nodes = {
},
gtfpga_node = {
type = "gtfpga",
-
+
### The following settings are specific to the gtfpga node-type!! ###
slot = "01:00.0", # The PCIe slot location (see first column in 'lspci' output)
id = "1ab8:4005", # The PCIe vendor:device ID (see third column in 'lspci -n' output)
-
+
rate = 1
},
ngsi_node = {
type = "ngsi",
-
+
### The following settings are specific to the ngsi node-type!! ###
endpoint = "http://46.101.131.212:1026",# The HTTP REST API endpoint of the FIRWARE context broker
-
- entity_id = "S3_ElectricalGrid",
+
+ entity_id = "S3_ElectricalGrid",
entity_type = "ElectricalGridMonitoring",
-
+
timeout = 5, # Timeout of HTTP request in seconds (default is 1)
verify_ssl = false, # Verification of SSL server certificates (default is true)
@@ -146,7 +146,7 @@ nodes = {
},
websocket_node = {
type = "websocket"
-
+
destinations = [ "http://example.com/node-name1", "https://example.com/another-node" ]
}
};
@@ -158,20 +158,20 @@ paths = (
{
enabled = true, # Enable this path (default: true)
reverse = true, # Setup a path in the reverse direction as well (default: false)
-
+
in = "acs", # Name of the node we receive messages from (see node dictionary)
out = "sintef", # Name of the node we send messages to.
-
+
rate = 100, # Send message over this path with a fixed (constant) rate (default: 0).
# Setting this value to 0 will disable this feature.
-
+
queuelen = 128,
samplelen = 64
},
{
enabled = false,
reverse = false,
-
+
in = "opal_node", # There's only a single source node allowed!
out = [ "udp_node", "tcp_node" ], # Multiple destination nodes are supported too.
},
diff --git a/etc/fpga-simple.conf b/etc/fpga-simple.conf
index 6dfe069c2..7143d9c56 100644
--- a/etc/fpga-simple.conf
+++ b/etc/fpga-simple.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,11 +34,11 @@ fpgas = {
/* Card identification */
id = "10ee:7022";
slot = "01:00.0";
-
+
intc = 0x5000;
reset = 0x2000;
do_reset = true;
-
+
ips = {
switch_0 = {
vlnv = "xilinx.com:ip:axis_interconnect:2.1"
@@ -57,7 +57,7 @@ fpgas = {
irq = 0
}
}
-
+
/* Configure switch_0 */
paths = (
{ in = "dma_0", out = "rtds_0" },
diff --git a/etc/fpga.conf b/etc/fpga.conf
index 6bcdfe4af..df9745ac2 100644
--- a/etc/fpga.conf
+++ b/etc/fpga.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,7 +45,7 @@ fpgas = {
# baseaddr Baseaddress as accessible from BAR0 memory region
# irq Interrupt index of MSI interrupt controller
# port Port index of AXI4-Stream interconnect
-
+
ips = {
### Utility IPs
axi_pcie_intc_0 = {
@@ -66,7 +66,7 @@ fpgas = {
baseaddr = 0x4000;
irq = 0;
},
-
+
### Data mover IPs
dma_0 = {
vlnv = "xilinx.com:ip:axi_dma:7.1";
@@ -87,7 +87,7 @@ fpgas = {
port = 2;
irq = 2;
},
-
+
### Interface IPs
rtds_axis_0 = {
vlnv = "acs.eonerc.rwth-aachen.de:user:rtds_axis:1.0";
@@ -95,14 +95,14 @@ fpgas = {
port = 0;
irq = 5; /* 5 -7 */
},
-
+
### Model IPs
hls_dft_0 = {
vlnv = "acs.eonerc.rwth-aachen.de:hls:hls_dft:1.0";
baseaddr = 0x9000;
port = 5;
irq = 1;
-
+
period = 400; /* in samples: 20ms / 50uS = 400*/
harmonics = [ 0, 1, 3, 5, 7 ]
decimation = 0; /* 0 = disabled */
diff --git a/etc/global.conf b/etc/global.conf
index e957f1a93..228c0fc51 100644
--- a/etc/global.conf
+++ b/etc/global.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -42,7 +42,7 @@ stats = 3; # The interval in seconds to print path statistics.
name = "villas-acs" # The name of this VILLASnode. Might by used by node-types
# to identify themselves (default is the hostname).
-
+
log = {
level = 5; # The level of verbosity for debug messages
# Higher number => increased verbosity
@@ -50,13 +50,13 @@ log = {
faciltities = [ "path", "socket" ]; # The list of enabled debug faciltities.
# If omitted, all faciltities are enabled
# For a full list of available faciltities, check lib/log.c
-
+
file = "/var/log/villas-node.log"; # File for logs
};
http = {
enabled = true, # Do not listen on port if true
-
+
htdocs = "/villas/web/socket/", # Root directory of internal webserver
port = 80 # Port for HTTP connections
}
\ No newline at end of file
diff --git a/etc/gtnet-skt/emulate_gtnet.conf b/etc/gtnet-skt/emulate_gtnet.conf
index 317d26c33..6f5eb9858 100644
--- a/etc/gtnet-skt/emulate_gtnet.conf
+++ b/etc/gtnet-skt/emulate_gtnet.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/gtnet-skt/test1.conf b/etc/gtnet-skt/test1.conf
index 57180ffba..71ad5a1d5 100644
--- a/etc/gtnet-skt/test1.conf
+++ b/etc/gtnet-skt/test1.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -56,7 +56,7 @@ paths = (
{
in = "node1", # Name of the node we listen to (see above)
out = "node1", # And we loop back to the origin
-
+
# Hooks
print = {
output = "stdout"
diff --git a/etc/gtnet-skt/test2.conf b/etc/gtnet-skt/test2.conf
index db14b4a84..a22c06db6 100644
--- a/etc/gtnet-skt/test2.conf
+++ b/etc/gtnet-skt/test2.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/gtnet-skt/test3.conf b/etc/gtnet-skt/test3.conf
index 6f8c5ec1d..e945e2cf4 100644
--- a/etc/gtnet-skt/test3.conf
+++ b/etc/gtnet-skt/test3.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/gtnet-skt/test4.conf b/etc/gtnet-skt/test4.conf
index 14da09ee6..7037b61e4 100644
--- a/etc/gtnet-skt/test4.conf
+++ b/etc/gtnet-skt/test4.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -56,7 +56,7 @@ paths = (
{
in = "node1", # Name of the node we listen to (see above)
out = "node1", # And we loop back to the origin
-
+
# Hooks
print = {
output = "stdout"
diff --git a/etc/gtnet-skt/test5.conf b/etc/gtnet-skt/test5.conf
index f7890bf41..43d429575 100644
--- a/etc/gtnet-skt/test5.conf
+++ b/etc/gtnet-skt/test5.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -57,7 +57,7 @@ paths = (
{
in = "node1", # Name of the node we listen to (see above)
out = "node1", # And we loop back to the origin
-
+
# Hooks
print = {
output = "stdout"
diff --git a/etc/loopback.conf b/etc/loopback.conf
index b625af64c..5cf8db653 100644
--- a/etc/loopback.conf
+++ b/etc/loopback.conf
@@ -35,12 +35,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/plugins.conf b/etc/plugins.conf
index 5261d075e..0a2de3174 100644
--- a/etc/plugins.conf
+++ b/etc/plugins.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/websocket-stats.conf b/etc/websocket-stats.conf
index a9680a6fb..3afd48353 100644
--- a/etc/websocket-stats.conf
+++ b/etc/websocket-stats.conf
@@ -17,12 +17,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/etc/websocket.conf b/etc/websocket.conf
index a633240c4..7ee096c80 100644
--- a/etc/websocket.conf
+++ b/etc/websocket.conf
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,7 +45,7 @@ nodes = {
{ label = "Sine", unit = "A" },
{ label = "Rect", unit = "Var"},
{ label = "Ramp", unit = "°C" }
- )
+ )
}
};
diff --git a/include/villas/advio.h b/include/villas/advio.h
index 91c57d29c..0e9bb5fe5 100644
--- a/include/villas/advio.h
+++ b/include/villas/advio.h
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -31,7 +31,7 @@
struct advio {
CURL *curl;
FILE *file;
-
+
unsigned char hash[SHA_DIGEST_LENGTH];
char mode[2];
diff --git a/include/villas/api.h b/include/villas/api.h
index 58f1707ca..e34863dd9 100644
--- a/include/villas/api.h
+++ b/include/villas/api.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -49,9 +49,9 @@ typedef int (*api_cb_t)(struct api_action *c, json_t *args, json_t **resp, struc
struct api {
struct list sessions; /**< List of currently active connections */
-
+
enum state state;
-
+
struct super_node *super_node;
};
diff --git a/include/villas/api/session.h b/include/villas/api/session.h
index b96f9d8af..6c239e501 100644
--- a/include/villas/api/session.h
+++ b/include/villas/api/session.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -43,7 +43,7 @@ enum api_mode {
struct api_session {
enum api_mode mode;
enum api_version version;
-
+
int runs;
struct {
@@ -54,11 +54,11 @@ struct api_session {
struct web_buffer body; /**< HTTP body / WS payload */
struct web_buffer headers; /**< HTTP headers */
} response;
-
+
bool completed; /**< Did we receive the complete body yet? */
-
+
enum state state;
-
+
struct api *api;
};
diff --git a/include/villas/atomic.h b/include/villas/atomic.h
index d40f6f70f..68ba72489 100644
--- a/include/villas/atomic.h
+++ b/include/villas/atomic.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/common.h b/include/villas/common.h
index 0206a3dfc..b32dc717c 100644
--- a/include/villas/common.h
+++ b/include/villas/common.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/compat.h b/include/villas/compat.h
index 8d27287ea..0c40bf005 100644
--- a/include/villas/compat.h
+++ b/include/villas/compat.h
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/crypt.h b/include/villas/crypt.h
index 6bd66fa1d..9b5c7843b 100644
--- a/include/villas/crypt.h
+++ b/include/villas/crypt.h
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -26,7 +26,7 @@
#include
/** Calculate SHA1 hash of complete file \p f and place it into \p sha1.
- *
+ *
* @param sha1[out] Must be SHA_DIGEST_LENGTH (20) in size.
* @retval 0 Everything was okay.
*/
diff --git a/include/villas/fpga/card.h b/include/villas/fpga/card.h
index 335646a4b..5dcd7a0d9 100644
--- a/include/villas/fpga/card.h
+++ b/include/villas/fpga/card.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -44,7 +44,7 @@ struct fpga_card {
struct pci *pci;
struct pci_device filter; /**< Filter for PCI device. */
-
+
struct vfio_container *vfio_container;
struct vfio_device vfio_device; /**< VFIO device handle. */
@@ -62,7 +62,7 @@ struct fpga_card {
struct fpga_ip *intc;
struct fpga_ip *reset;
struct fpga_ip *sw;
-
+
config_setting_t *cfg;
};
diff --git a/include/villas/fpga/ip.h b/include/villas/fpga/ip.h
index b3fb69250..36f540acd 100644
--- a/include/villas/fpga/ip.h
+++ b/include/villas/fpga/ip.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -68,7 +68,7 @@ struct fpga_ip_type {
int (*destroy)(struct fpga_ip *c);
int (*reset)(struct fpga_ip *c);
void (*dump)(struct fpga_ip *c);
-
+
size_t size; /**< Amount of memory which should be reserved for struct fpga_ip::_vd */
};
diff --git a/include/villas/fpga/ips/dft.h b/include/villas/fpga/ips/dft.h
index 5157b1c26..345614653 100644
--- a/include/villas/fpga/ips/dft.h
+++ b/include/villas/fpga/ips/dft.h
@@ -18,7 +18,7 @@ struct ip;
struct dft {
XHls_dft inst;
-
+
int period; /* in samples */
int num_harmonics;
float *fharmonics;
diff --git a/include/villas/fpga/ips/dma.h b/include/villas/fpga/ips/dma.h
index 2e5df2f18..95eb981be 100644
--- a/include/villas/fpga/ips/dma.h
+++ b/include/villas/fpga/ips/dma.h
@@ -12,7 +12,7 @@
*/
#pragma once
-
+
#include
#include
#include
diff --git a/include/villas/fpga/ips/fifo.h b/include/villas/fpga/ips/fifo.h
index 148695e1a..5ac7d888e 100644
--- a/include/villas/fpga/ips/fifo.h
+++ b/include/villas/fpga/ips/fifo.h
@@ -20,7 +20,7 @@
struct fifo {
XLlFifo inst;
-
+
uint32_t baseaddr_axi4;
};
diff --git a/include/villas/fpga/ips/intc.h b/include/villas/fpga/ips/intc.h
index b4898730b..bef447ed9 100644
--- a/include/villas/fpga/ips/intc.h
+++ b/include/villas/fpga/ips/intc.h
@@ -22,7 +22,7 @@ struct intc {
int efds[32]; /**< Event FDs */
int nos[32]; /**< Interrupt numbers from /proc/interrupts */
-
+
int flags[32]; /**< Mask of intc_flags */
};
diff --git a/include/villas/fpga/vlnv.h b/include/villas/fpga/vlnv.h
index 43bc5d093..554968b74 100644
--- a/include/villas/fpga/vlnv.h
+++ b/include/villas/fpga/vlnv.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/hist.h b/include/villas/hist.h
index 8f69233d2..81109d995 100644
--- a/include/villas/hist.h
+++ b/include/villas/hist.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -36,22 +36,22 @@ typedef uintmax_t hist_cnt_t;
/** Histogram structure used to collect statistics. */
struct hist {
double resolution; /**< The distance between two adjacent buckets. */
-
+
double high; /**< The value of the highest bucket. */
double low; /**< The value of the lowest bucket. */
-
+
double highest; /**< The highest value observed (may be higher than #high). */
double lowest; /**< The lowest value observed (may be lower than #low). */
double last; /**< The last value which has been put into the buckets */
-
+
int length; /**< The number of buckets in #data. */
hist_cnt_t total; /**< Total number of counted values. */
- hist_cnt_t higher; /**< The number of values which are higher than #high. */
+ hist_cnt_t higher; /**< The number of values which are higher than #high. */
hist_cnt_t lower; /**< The number of values which are lower than #low. */
hist_cnt_t *data; /**< Pointer to dynamically allocated array of size length. */
-
+
double _m[2], _s[2]; /**< Private variables for online variance calculation */
};
diff --git a/include/villas/hook.h b/include/villas/hook.h
index 83686eca9..c1b120b42 100644
--- a/include/villas/hook.h
+++ b/include/villas/hook.h
@@ -17,12 +17,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -31,7 +31,7 @@
* @ingroup path
* @{
*********************************************************************************/
-
+
#pragma once
#include
@@ -55,15 +55,15 @@ struct hook_type {
bool builtin; /**< Should we add this hook by default to every path?. */
size_t size; /**< Size of allocation for struct hook::_vd */
-
+
int (*parse)(struct hook *h, config_setting_t *cfg);
int (*init)(struct hook *h); /**< Called before path is started to parseHOOK_DESTROYs. */
- int (*destroy)(struct hook *h); /**< Called after path has been stopped to release memory allocated by HOOK_INIT */
+ int (*destroy)(struct hook *h); /**< Called after path has been stopped to release memory allocated by HOOK_INIT */
int (*start)(struct hook *h); /**< Called whenever a path is started; before threads are created. */
int (*stop)(struct hook *h); /**< Called whenever a path is stopped; after threads are destoyed. */
-
+
int (*periodic)(struct hook *h);/**< Called periodically. Period is set by global 'stats' option in the configuration file. */
int (*restart)(struct hook *h); /**< Called whenever a new simulation case is started. This is detected by a sequence no equal to zero. */
@@ -77,10 +77,10 @@ struct hook {
struct sample *prev, *last;
struct path *path;
-
+
struct hook_type *_vt; /**< C++ like Vtable pointer. */
void *_vd; /**< Private data for this hook. This pointer can be used to pass data between consecutive calls of the callback. */
-
+
int priority; /**< A priority to change the order of execution within one type of hook. */
};
diff --git a/include/villas/json.h b/include/villas/json.h
index a249b80fa..481a18839 100644
--- a/include/villas/json.h
+++ b/include/villas/json.h
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/kernel/if.h b/include/villas/kernel/if.h
index 063c3d3fd..2606b1014 100644
--- a/include/villas/kernel/if.h
+++ b/include/villas/kernel/if.h
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/kernel/kernel.h b/include/villas/kernel/kernel.h
index 4603a4bf5..05a8ab913 100644
--- a/include/villas/kernel/kernel.h
+++ b/include/villas/kernel/kernel.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/kernel/nl.h b/include/villas/kernel/nl.h
index a2cf10280..5e73837e7 100644
--- a/include/villas/kernel/nl.h
+++ b/include/villas/kernel/nl.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@
* @retval >=0 Interface index of outgoing interface.
* @retval <0 Error. Something went wrong.
*/
-int nl_get_egress(struct nl_addr *addr);
+int nl_get_egress(struct nl_addr *addr);
/** Get or create global netlink socket. */
struct nl_sock * nl_init();
diff --git a/include/villas/kernel/pci.h b/include/villas/kernel/pci.h
index 9f5686972..180308247 100644
--- a/include/villas/kernel/pci.h
+++ b/include/villas/kernel/pci.h
@@ -20,7 +20,7 @@ struct pci_device {
int device;
int class;
} id;
-
+
struct {
int domain;
int bus;
diff --git a/include/villas/kernel/rt.h b/include/villas/kernel/rt.h
index 4b6f8ef14..2329f19c5 100644
--- a/include/villas/kernel/rt.h
+++ b/include/villas/kernel/rt.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/kernel/tc.h b/include/villas/kernel/tc.h
index f7f194528..f959a57e8 100644
--- a/include/villas/kernel/tc.h
+++ b/include/villas/kernel/tc.h
@@ -16,12 +16,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/list.h b/include/villas/list.h
index 00ff9ee15..6615c665f 100644
--- a/include/villas/list.h
+++ b/include/villas/list.h
@@ -28,7 +28,7 @@
.lock = PTHREAD_MUTEX_INITIALIZER, \
.state = STATE_INITIALIZED \
}
-
+
#define list_length(list) ((list)->length)
#define list_at_safe(list, index) ((list)->length > index ? (list)->array[index] : NULL)
#define list_at(list, index) ((list)->array[index])
@@ -42,7 +42,7 @@
*/
typedef int (*dtor_cb_t)(void *);
-/** Callback to search or sort a list. */
+/** Callback to search or sort a list. */
typedef int (*cmp_cb_t)(const void *, const void *);
/* The list data structure. */
diff --git a/include/villas/log.h b/include/villas/log.h
index e16a0aec4..58e8b0509 100644
--- a/include/villas/log.h
+++ b/include/villas/log.h
@@ -11,16 +11,16 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
-
+
#pragma once
#ifdef __cplusplus
@@ -41,7 +41,7 @@ extern "C" {
/* The log level which is passed as first argument to print() */
#define LOG_LVL_DEBUG GRY("Debug")
-#define LOG_LVL_INFO WHT("Info ")
+#define LOG_LVL_INFO WHT("Info ")
#define LOG_LVL_WARN YEL("Warn ")
#define LOG_LVL_ERROR RED("Error")
#define LOG_LVL_STATS MAG("Stats")
@@ -66,7 +66,7 @@ enum log_facilities {
LOG_XIL = (1L << 20),
LOG_TC = (1L << 21),
LOG_IF = (1L << 22),
-
+
/* Node-types */
LOG_SOCKET = (1L << 23),
LOG_FILE = (1L << 24),
@@ -74,16 +74,16 @@ enum log_facilities {
LOG_NGSI = (1L << 26),
LOG_WEBSOCKET = (1L << 27),
LOG_OPAL = (1L << 28),
-
+
/* Classes */
LOG_NODES = LOG_NODE | LOG_SOCKET | LOG_FILE | LOG_FPGA | LOG_NGSI | LOG_WEBSOCKET | LOG_OPAL,
LOG_KERNEL = LOG_VFIO | LOG_PCI | LOG_TC | LOG_IF,
- LOG_ALL = ~0xFF
+ LOG_ALL = ~0xFF
};
struct log {
enum state state;
-
+
struct timespec epoch; /**< A global clock used to prefix the log messages. */
/** Debug level used by the debug() macro.
@@ -93,10 +93,10 @@ struct log {
/** Debug facilities used by the debug() macro. */
long facilities;
-
+
/** Path of the log file */
const char *path;
-
+
/** Send all log output to this file / stdout / stderr */
FILE *file;
};
@@ -136,7 +136,7 @@ void log_outdent(int *);
*
* The first case enables only faciltities which are in the list.
* The second case enables all faciltities with exception of those which are in the list.
- *
+ *
* @param expression The expression
* @return The new facilties mask (see enum log_faciltities)
*/
@@ -155,7 +155,7 @@ void log_print(struct log *l, const char *lvl, const char *fmt, ...)
* @param lvl The log level
* @param fmt The format string (printf alike)
* @param va The variadic argument list (see stdarg.h)
- */
+ */
void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list va);
/** Printf alike debug message with level. */
diff --git a/include/villas/log_config.h b/include/villas/log_config.h
index 11ffbe5da..7e898f82b 100644
--- a/include/villas/log_config.h
+++ b/include/villas/log_config.h
@@ -11,16 +11,16 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
-
+
#pragma once
struct log;
diff --git a/include/villas/mapping.h b/include/villas/mapping.h
index 44f79444c..3704d04f5 100644
--- a/include/villas/mapping.h
+++ b/include/villas/mapping.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -79,7 +79,7 @@ struct mapping_entry {
struct mapping {
enum state state;
-
+
int real_length;
struct list entries;
diff --git a/include/villas/memory.h b/include/villas/memory.h
index 0917a4586..87117f3b3 100644
--- a/include/villas/memory.h
+++ b/include/villas/memory.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -43,9 +43,9 @@ enum memtype_flags {
struct memtype {
const char *name;
int flags;
-
+
size_t alignment;
-
+
memzone_allocator_t alloc;
memzone_deallocator_t free;
@@ -68,10 +68,10 @@ struct memblock {
/** @todo Unused for now */
struct memzone {
struct memtype * const type;
-
+
void *addr;
uintptr_t physaddr;
- size_t len;
+ size_t len;
};
/** Initilialize memory subsystem */
diff --git a/include/villas/msg.h b/include/villas/msg.h
index 594662b41..27c8e8bb6 100644
--- a/include/villas/msg.h
+++ b/include/villas/msg.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/msg_format.h b/include/villas/msg_format.h
index beeca4c1b..bf876093d 100644
--- a/include/villas/msg_format.h
+++ b/include/villas/msg_format.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -66,10 +66,10 @@ struct msg
unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */
unsigned rsvd1 : 2; /**< Reserved bits */
unsigned rsvd2 : 8; /**< Reserved bits */
-
+
uint16_t length; /**< The number of values in msg::data[]. */
uint32_t sequence; /**< The sequence number is incremented by one for consecutive messages. */
-
+
/** A timestamp per message. */
struct {
uint32_t sec; /**< Seconds since 1970-01-01 00:00:00 */
diff --git a/include/villas/node.h b/include/villas/node.h
index da5fbff99..04d113624 100644
--- a/include/villas/node.h
+++ b/include/villas/node.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
@@ -50,13 +50,13 @@ struct node
int vectorize; /**< Number of messages to send / recv at once (scatter / gather) */
int affinity; /**< CPU Affinity of this node */
-
+
int id; /**< An id of this node which is only unique in the scope of it's super-node (VILLASnode instance). */
unsigned long sequence; /**< This is a counter of received samples, in case the node-type does not generate sequence numbers itself. */
-
+
enum state state;
-
+
struct node_type *_vt; /**< Virtual functions (C++ OOP style) */
void *_vd; /**< Virtual data (used by struct node::_vt functions) */
diff --git a/include/villas/node_type.h b/include/villas/node_type.h
index d917c1f08..d0dcdc8d1 100644
--- a/include/villas/node_type.h
+++ b/include/villas/node_type.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
@@ -42,9 +42,9 @@ struct node_type {
struct list instances; /**< A list of all existing nodes of this type. */
size_t size; /**< Size of private data bock. @see node::_vd */
-
+
enum state state;
-
+
/** Global initialization per node type.
*
* This callback is invoked once per node-type.
@@ -62,13 +62,13 @@ struct node_type {
* @retval <0 Error. Something went wrong.
*/
int (*deinit)();
-
- /** Allocate memory for an instance of this type.
+
+ /** Allocate memory for an instance of this type.
*
* @return A pointer to the node-type specific private data.
*/
void * (*create)();
-
+
/** Free memory of an instance of this type.
*
* @param n A pointer to the node object.
@@ -135,7 +135,7 @@ struct node_type {
* @return The number of messages actually sent.
*/
int (*write)(struct node *n, struct sample *smps[], unsigned cnt);
-
+
/** Reverse source and destination of a node.
*
* This is not supported by all node types!
diff --git a/include/villas/nodes/cbuilder.h b/include/villas/nodes/cbuilder.h
index cb83ced7f..adcc8dba5 100644
--- a/include/villas/nodes/cbuilder.h
+++ b/include/villas/nodes/cbuilder.h
@@ -8,7 +8,7 @@
/**
* @addtogroup cbuilder RTDS CBuilder model node
* @ingroup node
- * @{
+ * @{
*/
#pragma once
@@ -23,7 +23,7 @@ struct cbuilder;
struct cbuilder_model {
void (*code)();
void (*ram)();
-
+
int (*init)(struct cbuilder *cb);
int (*read)(float inputs[], int len);
int (*write)(float outputs[], int len);
@@ -34,7 +34,7 @@ struct cbuilder {
double timestep;
struct cbuilder_model *model;
-
+
float *params;
int paramlen;
diff --git a/include/villas/nodes/file.h b/include/villas/nodes/file.h
index 882eb714d..35b873eeb 100644
--- a/include/villas/nodes/file.h
+++ b/include/villas/nodes/file.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -50,7 +50,7 @@ struct file {
char *uri; /**< Real file name. */
} read, write;
-
+
int rewind; /**< Should we rewind the file when we reach EOF? */
enum read_epoch_mode {
diff --git a/include/villas/nodes/fpga.h b/include/villas/nodes/fpga.h
index d181af0a0..ece227bf5 100644
--- a/include/villas/nodes/fpga.h
+++ b/include/villas/nodes/fpga.h
@@ -29,7 +29,7 @@ struct fpga_ip;
/** The node type */
struct fpga {
struct fpga_ip *ip;
-
+
struct pci *pci;
struct vfio_container *vfio_container;
diff --git a/include/villas/nodes/ngsi.h b/include/villas/nodes/ngsi.h
index 2653f7e64..7cd9c6814 100644
--- a/include/villas/nodes/ngsi.h
+++ b/include/villas/nodes/ngsi.h
@@ -17,12 +17,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/nodes/opal.h b/include/villas/nodes/opal.h
index a0c38200d..ecc534536 100644
--- a/include/villas/nodes/opal.h
+++ b/include/villas/nodes/opal.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -49,7 +49,7 @@ struct opal {
int send_id;
int recv_id;
-
+
Opal_SendAsyncParam send_params;
Opal_RecvAsyncParam recv_params;
};
diff --git a/include/villas/nodes/shmem.h b/include/villas/nodes/shmem.h
index ff059a292..91676d00b 100644
--- a/include/villas/nodes/shmem.h
+++ b/include/villas/nodes/shmem.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/nodes/socket.h b/include/villas/nodes/socket.h
index a7d7524ff..9714bf834 100644
--- a/include/villas/nodes/socket.h
+++ b/include/villas/nodes/socket.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -58,7 +58,7 @@ union sockaddr_union {
struct socket {
int sd; /**> The socket descriptor */
int mark; /**> Socket mark for netem, routing and filtering */
-
+
enum {
SOCKET_ENDIAN_LITTLE,
SOCKET_ENDIAN_BIG
diff --git a/include/villas/nodes/websocket.h b/include/villas/nodes/websocket.h
index e3baa20c3..5203db542 100644
--- a/include/villas/nodes/websocket.h
+++ b/include/villas/nodes/websocket.h
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -50,7 +50,7 @@ struct lws;
struct websocket {
struct list connections; /**< List of active libwebsocket connections in server mode (struct websocket_connection). */
struct list destinations; /**< List of websocket servers connect to in client mode (struct websocket_destination). */
-
+
struct pool pool;
struct queue_signalled queue; /**< For samples which are received from WebSockets */
};
@@ -59,21 +59,21 @@ struct websocket {
struct websocket_connection {
struct node *node;
struct lws *wsi;
-
- struct queue queue; /**< For samples which are sent to the WebSocket */
-
+
+ struct queue queue; /**< For samples which are sent to the WebSocket */
+
struct {
char name[64];
char ip[64];
} peer;
-
+
enum {
WEBSOCKET_MODE_CLIENT,
WEBSOCKET_MODE_SERVER,
} mode;
-
+
enum state state;
-
+
char *_name;
};
diff --git a/include/villas/path.h b/include/villas/path.h
index 9d54e3451..a32a5fe6e 100644
--- a/include/villas/path.h
+++ b/include/villas/path.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -48,7 +48,7 @@ struct path_source
struct node *node;
struct pool pool;
int samplelen;
- pthread_t tid;
+ pthread_t tid;
};
struct path_destination
@@ -63,7 +63,7 @@ struct path_destination
struct path
{
enum state state; /**< Path state. */
-
+
/* Each path has a single source and multiple destinations */
struct path_source *source; /**< Pointer to the incoming node */
struct list destinations; /**< List of all outgoing nodes (struct path_destination). */
@@ -72,16 +72,16 @@ struct path
int enabled; /**< Is this path enabled. */
int reverse; /**< This path as a matching reverse path. */
-
+
int samplelen;
int queuelen;
pthread_t tid; /**< The thread id for this path. */
-
+
char *_name; /**< Singleton: A string which is used to print this path to screen. */
-
+
struct stats *stats; /**< Statistic counters. This is a pointer to the statistic hooks private data. */
-
+
struct super_node *super_node; /**< The super node this path belongs to. */
config_setting_t *cfg; /**< A pointer to the libconfig object which instantiated this path. */
};
diff --git a/include/villas/plugin.h b/include/villas/plugin.h
index 6f7042fba..7d00ca791 100644
--- a/include/villas/plugin.h
+++ b/include/villas/plugin.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -55,14 +55,14 @@ struct plugin {
char *description;
void *handle;
char *path;
-
+
enum plugin_type type;
enum state state;
-
+
int (*load)(struct plugin *p);
int (*unload)(struct plugin *p);
-
+
union {
struct api_action api;
struct node_type node;
diff --git a/include/villas/pool.h b/include/villas/pool.h
index 37f842e14..713a7bef7 100644
--- a/include/villas/pool.h
+++ b/include/villas/pool.h
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -36,18 +36,18 @@
struct pool {
off_t buffer_off; /**< Offset from the struct address to the underlying memory area */
struct memtype *mem;
-
+
enum state state;
-
+
size_t len; /**< Length of the underlying memory area */
-
+
size_t blocksz; /**< Length of a block in bytes */
size_t alignment; /**< Alignment of a block in bytes */
-
+
struct queue queue; /**< The queue which is used to keep track of free blocks */
};
-#define INLINE static inline __attribute__((unused))
+#define INLINE static inline __attribute__((unused))
/** Initiazlize a pool
*
diff --git a/include/villas/queue.h b/include/villas/queue.h
index fa88fb8d8..62b88d268 100644
--- a/include/villas/queue.h
+++ b/include/villas/queue.h
@@ -6,19 +6,19 @@
* @author Steffen Vogel
* @copyright 2017 Steffen Vogel
* @license BSD 2-Clause License
- *
+ *
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modiffication, are permitted provided that the following conditions are met:
- *
+ *
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -55,7 +55,7 @@ struct queue_cell {
/** A lock-free multiple-producer, multiple-consumer (MPMC) queue. */
struct queue {
cacheline_pad_t _pad0; /**< Shared area: all threads read */
-
+
enum state state;
struct memtype *mem;
@@ -83,7 +83,7 @@ int queue_destroy(struct queue *q);
*
* Note: This is only an estimation and not accurate as long other
* threads are performing operations.
- */
+ */
size_t queue_available(struct queue *q);
int queue_push(struct queue *q, void *ptr);
diff --git a/include/villas/queue_signalled.h b/include/villas/queue_signalled.h
index 9c90e03df..6974e00cd 100644
--- a/include/villas/queue_signalled.h
+++ b/include/villas/queue_signalled.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/sample.h b/include/villas/sample.h
index b2d2902e5..f7fbffe56 100644
--- a/include/villas/sample.h
+++ b/include/villas/sample.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -56,7 +56,7 @@ struct sample {
int sequence; /**< The sequence number of this sample. */
int length; /**< The number of values in sample::values which are valid. */
int capacity; /**< The number of values in sample::values for which memory is reserved. */
-
+
atomic_int refcnt; /**< Reference counter. */
off_t pool_off; /**< This sample belongs to this memory pool (relative pointer). */
struct node *source; /**< The node from which this sample originates. */
@@ -67,7 +67,7 @@ struct sample {
struct timespec received; /**< The point in time when this data was received. */
struct timespec sent; /**< The point in time when this data was send for the last time. */
} ts;
-
+
uint64_t format; /**< A long bitfield indicating the number representation of the first 64 values in sample::data[] */
/** The values. */
diff --git a/include/villas/sample_io.h b/include/villas/sample_io.h
index 7e307e941..d900a0e05 100644
--- a/include/villas/sample_io.h
+++ b/include/villas/sample_io.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/shmem.h b/include/villas/shmem.h
index 1c3093028..39d5d5390 100644
--- a/include/villas/shmem.h
+++ b/include/villas/shmem.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/stats.h b/include/villas/stats.h
index ad02bafc6..9c0e89c80 100644
--- a/include/villas/stats.h
+++ b/include/villas/stats.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -55,13 +55,13 @@ enum stats_id {
struct stats_delta {
double values[STATS_COUNT];
-
+
int update; /**< Bitmask of stats_id. Only those which are masked will be updated */
struct sample *last;
};
struct stats {
- struct hist histograms[STATS_COUNT];
+ struct hist histograms[STATS_COUNT];
struct stats_delta *delta;
};
diff --git a/include/villas/super_node.h b/include/villas/super_node.h
index e82aacb91..fa36d8161 100644
--- a/include/villas/super_node.h
+++ b/include/villas/super_node.h
@@ -15,12 +15,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -49,12 +49,12 @@ struct super_node {
struct log log;
struct api api;
struct web web;
-
+
struct {
int argc;
char **argv;
} cli;
-
+
enum state state;
config_t cfg; /**< Pointer to configuration file */
diff --git a/include/villas/timing.h b/include/villas/timing.h
index 0460fad09..de25e3d9c 100644
--- a/include/villas/timing.h
+++ b/include/villas/timing.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -25,7 +25,7 @@
#include
#include
-
+
#include
#include
diff --git a/include/villas/utils.h b/include/villas/utils.h
index 644ff5022..39c7e7031 100644
--- a/include/villas/utils.h
+++ b/include/villas/utils.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/web.h b/include/villas/web.h
index cb53240b8..782683e93 100644
--- a/include/villas/web.h
+++ b/include/villas/web.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -33,9 +33,9 @@ struct api;
struct web {
struct api *api;
-
+
enum state state;
-
+
struct lws_context *context; /**< The libwebsockets server context. */
struct lws_vhost *vhost; /**< The libwebsockets vhost. */
@@ -43,7 +43,7 @@ struct web {
const char *htdocs; /**< The root directory for files served via HTTP. */
const char *ssl_cert; /**< Path to the SSL certitifcate for HTTPS / WSS. */
const char *ssl_private_key; /**< Path to the SSL private key for HTTPS / WSS. */
-
+
pthread_t thread;
};
diff --git a/include/villas/web/buffer.h b/include/villas/web/buffer.h
index c342f7c7c..88a3d755f 100644
--- a/include/villas/web/buffer.h
+++ b/include/villas/web/buffer.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -36,7 +36,7 @@ struct web_buffer {
size_t prefix; /**< The used length of the buffer. */
enum lws_write_protocol protocol;
-
+
enum state state;
};
diff --git a/include/villas/webmsg.h b/include/villas/webmsg.h
index 613ff000b..686bfd01d 100644
--- a/include/villas/webmsg.h
+++ b/include/villas/webmsg.h
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/include/villas/webmsg_format.h b/include/villas/webmsg_format.h
index ffcf5a497..ea81beb92 100644
--- a/include/villas/webmsg_format.h
+++ b/include/villas/webmsg_format.h
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -71,10 +71,10 @@ struct webmsg
uint8_t id; /**< The node index from / to which this sample received / sent to.
* Corresponds to the index of the node in the http://localhost/nodes.json array. */
-
+
uint16_t length; /**< The number of values in msg::data[]. */
uint32_t sequence; /**< The sequence number is incremented by one for consecutive messages. */
-
+
/** A timestamp per message. */
struct {
uint32_t sec; /**< Seconds since 1970-01-01 00:00:00 */
diff --git a/lib/advio.c b/lib/advio.c
index 57fb88ee9..a192a70c3 100644
--- a/lib/advio.c
+++ b/lib/advio.c
@@ -12,12 +12,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -80,9 +80,9 @@ AFILE * afopen(const char *uri, const char *mode)
int ret;
AFILE *af = alloc(sizeof(AFILE));
-
+
strncpy(af->mode, mode, sizeof(af->mode));
-
+
af->uri = strdup(uri);
if (!af->uri)
goto out2;
@@ -90,7 +90,7 @@ AFILE * afopen(const char *uri, const char *mode)
af->file = tmpfile();
if (!af->file)
goto out2;
-
+
af->curl = curl_easy_init();
if (!af->curl)
goto out1;
@@ -107,7 +107,7 @@ AFILE * afopen(const char *uri, const char *mode)
curl_easy_setopt(af->curl, CURLOPT_XFERINFOFUNCTION, advio_xferinfo);
curl_easy_setopt(af->curl, CURLOPT_XFERINFODATA, af);
curl_easy_setopt(af->curl, CURLOPT_NOPROGRESS, 0L);
-
+
ret = adownload(af);
if (ret)
goto out0;
@@ -125,15 +125,15 @@ out2: free(af->uri);
int afclose(AFILE *af)
{
int ret;
-
+
ret = afflush(af);
curl_easy_cleanup(af->curl);
fclose(af->file);
-
+
free(af->uri);
free(af);
-
+
return ret;
}
@@ -141,11 +141,11 @@ int afflush(AFILE *af)
{
bool dirty;
unsigned char hash[SHA_DIGEST_LENGTH];
-
+
/* Check if fle was modified on disk by comparing hashes */
sha1sum(af->file, hash);
dirty = memcmp(hash, af->hash, sizeof(hash));
-
+
if (dirty)
return aupload(af);
@@ -174,7 +174,7 @@ int aupload(AFILE *af)
fflush(stderr); /* do not continue in the same line as the progress bar */
fseek(af->file, pos, SEEK_SET); /* Restore old stream pointer */
-
+
if (res != CURLE_OK)
return -1;
@@ -192,10 +192,10 @@ int adownload(AFILE *af)
fseek(af->file, 0, SEEK_SET);
res = curl_easy_perform(af->curl);
-
+
fprintf(stderr, "\e[2K");
fflush(stderr); /* do not continue in the same line as the progress bar */
-
+
switch (res) {
case CURLE_OK:
curl_easy_getinfo(af->curl, CURLINFO_RESPONSE_CODE, &code);
@@ -207,7 +207,7 @@ int adownload(AFILE *af)
}
/* The following error codes indicate that the file does not exist
- * Check the fopen mode to see if we should continue with an emoty file */
+ * Check the fopen mode to see if we should continue with an emoty file */
case CURLE_FILE_COULDNT_READ_FILE:
case CURLE_TFTP_NOTFOUND:
case CURLE_REMOTE_FILE_NOT_FOUND:
@@ -218,7 +218,7 @@ int adownload(AFILE *af)
af->file = fopen(af->uri, af->mode);
if (!af->file)
return -1;
-
+
default:
error("Failed to fetch file: %s: %s\n", af->uri, curl_easy_strerror(res));
return -1;
@@ -245,7 +245,7 @@ exist: /* File exists */
fseek(af->file, 0, SEEK_END);
else if (af->mode[0] == 'r' || af->mode[0] == 'w')
fseek(af->file, 0, SEEK_SET);
-
+
sha1sum(af->file, af->hash);
return 0;
diff --git a/lib/api.c b/lib/api.c
index e5e0d61fc..9c990ca76 100644
--- a/lib/api.c
+++ b/lib/api.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -47,11 +47,11 @@ int api_ws_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *
/* Parse request URI */
char uri[64];
lws_hdr_copy(wsi, uri, sizeof(uri), WSI_TOKEN_GET_URI); /* The path component of the*/
-
+
ret = sscanf(uri, "/v%d", (int *) &s->version);
if (ret != 1)
return -1;
-
+
ret = api_session_init(s, w->api, API_MODE_WS);
if (ret)
return -1;
@@ -63,9 +63,9 @@ int api_ws_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *
ret = api_session_destroy(s);
if (ret)
return -1;
-
+
debug(LOG_API, "Closed API session");
-
+
break;
case LWS_CALLBACK_SERVER_WRITEABLE:
@@ -75,14 +75,14 @@ int api_ws_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *
return -1;
break;
-
+
case LWS_CALLBACK_RECEIVE:
web_buffer_append(&s->request.body, in, len);
-
+
json_t *req, *resp;
while (web_buffer_read_json(&s->request.body, &req) >= 0) {
api_session_run_command(s, req, &resp);
-
+
web_buffer_append_json(&s->response.body, resp);
lws_callback_on_writable(wsi);
}
@@ -138,7 +138,7 @@ int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void
s->completed = true;
break;
-
+
case LWS_CALLBACK_CLOSED_HTTP:
ret = api_session_destroy(s);
if (ret)
@@ -147,7 +147,7 @@ int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void
case LWS_CALLBACK_HTTP_BODY:
web_buffer_append(&s->request.body, in, len);
-
+
json_t *req, *resp;
while (web_buffer_read_json(&s->request.body, &req) == 1) {
api_session_run_command(s, req, &resp);
@@ -211,8 +211,8 @@ int api_stop(struct api *a)
info("Stopping API sub-system");
list_destroy(&a->sessions, (dtor_cb_t) api_session_destroy, false);
-
+
a->state = STATE_STOPPED;
-
+
return 0;
}
diff --git a/lib/api/actions/capabiltities.c b/lib/api/actions/capabiltities.c
index be5a4a767..5a91d868a 100644
--- a/lib/api/actions/capabiltities.c
+++ b/lib/api/actions/capabiltities.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -28,10 +28,10 @@ static int api_capabilities(struct api_action *h, json_t *args, json_t **resp, s
json_t *json_apis = json_array();
json_t *json_nodes = json_array();
json_t *json_name;
-
+
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *p = list_at(&plugins, i);
-
+
json_name = json_string(p->name);
switch (p->type) {
@@ -41,13 +41,13 @@ static int api_capabilities(struct api_action *h, json_t *args, json_t **resp, s
default: { }
}
}
-
+
*resp = json_pack("{ s: s, s: o, s: o, s: o }",
"build", BUILDID,
"hooks", json_hooks,
"node-types", json_nodes,
"apis", json_apis);
-
+
return 0;
}
diff --git a/lib/api/actions/config.c b/lib/api/actions/config.c
index a87dc31c7..24e4a44e5 100644
--- a/lib/api/actions/config.c
+++ b/lib/api/actions/config.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -30,9 +30,9 @@
static int api_config(struct api_action *h, json_t *args, json_t **resp, struct api_session *s)
{
config_setting_t *cfg_root = config_root_setting(&s->api->super_node->cfg);
-
+
*resp = cfg_root ? config_to_json(cfg_root) : json_object();
-
+
return 0;
}
diff --git a/lib/api/actions/nodes.c b/lib/api/actions/nodes.c
index e4d8da0fb..1add05f42 100644
--- a/lib/api/actions/nodes.c
+++ b/lib/api/actions/nodes.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,14 +45,14 @@ static int api_nodes(struct api_action *r, json_t *args, json_t **resp, struct a
"affinity", n->affinity,
"id", i
);
-
+
/* Add all additional fields of node here.
- * This can be used for metadata */
+ * This can be used for metadata */
json_object_update(json_node, config_to_json(n->cfg));
-
+
json_array_append_new(json_nodes, json_node);
}
-
+
*resp = json_nodes;
return 0;
diff --git a/lib/api/actions/reload.c b/lib/api/actions/reload.c
index 99bcb70db..53239b61b 100644
--- a/lib/api/actions/reload.c
+++ b/lib/api/actions/reload.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/lib/api/session.c b/lib/api/session.c
index e625f8e51..258e7411f 100644
--- a/lib/api/session.c
+++ b/lib/api/session.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -29,9 +29,9 @@ int api_session_init(struct api_session *s, struct api *a, enum api_mode m)
{
s->mode = m;
s->api = a;
-
+
s->completed = false;
-
+
web_buffer_init(&s->request.body, s->mode == API_MODE_HTTP ? LWS_WRITE_HTTP : LWS_WRITE_TEXT);
web_buffer_init(&s->response.body, s->mode == API_MODE_HTTP ? LWS_WRITE_HTTP : LWS_WRITE_TEXT);
@@ -45,15 +45,15 @@ int api_session_destroy(struct api_session *s)
{
if (s->state == STATE_DESTROYED)
return 0;
-
+
web_buffer_destroy(&s->request.body);
web_buffer_destroy(&s->response.body);
-
+
if (s->mode == API_MODE_HTTP)
web_buffer_destroy(&s->response.headers);
-
+
s->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -63,9 +63,9 @@ int api_session_run_command(struct api_session *s, json_t *json_in, json_t **jso
const char *action;
char *id;
struct plugin *p;
-
+
json_t *json_args = NULL, *json_resp;
-
+
ret = json_unpack(json_in, "{ s: s, s: s, s?: o }",
"action", &action,
"id", &id,
@@ -77,7 +77,7 @@ int api_session_run_command(struct api_session *s, json_t *json_in, json_t **jso
"code", ret);
goto out;
}
-
+
p = plugin_lookup(PLUGIN_TYPE_API, action);
if (!p) {
ret = -101;
diff --git a/lib/compat.c b/lib/compat.c
index 90733b504..446765a8a 100644
--- a/lib/compat.c
+++ b/lib/compat.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@ size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags)
str = json_dumps(json, flags);
if (!str)
return 0;
-
+
len = strlen(str); // not \0 terminated
if (buffer && len <= size)
memcpy(buffer, str, len);
diff --git a/lib/crypt.c b/lib/crypt.c
index 26ddc3eb2..1e84bffa1 100644
--- a/lib/crypt.c
+++ b/lib/crypt.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -28,7 +28,7 @@ int sha1sum(FILE *f, unsigned char *sha1)
char buf[512];
ssize_t bytes;
long seek;
-
+
seek = ftell(f);
fseek(f, 0, SEEK_SET);
@@ -41,7 +41,7 @@ int sha1sum(FILE *f, unsigned char *sha1)
}
SHA1_Final(sha1, &c);
-
+
fseek(f, seek, SEEK_SET);
return 0;
diff --git a/lib/fpga/card.c b/lib/fpga/card.c
index d9dfada2c..4a504f0c4 100644
--- a/lib/fpga/card.c
+++ b/lib/fpga/card.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -40,18 +40,18 @@ int fpga_card_init(struct fpga_card *c, struct pci *pci, struct vfio_container *
c->vfio_container = vc;
c->pci = pci;
-
+
list_init(&c->ips);
-
+
/* Default values */
c->filter.id.vendor = FPGA_PCI_VID_XILINX;
c->filter.id.device = FPGA_PCI_PID_VFPGA;
-
+
c->affinity = 0;
c->do_reset = 0;
-
+
c->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -89,7 +89,7 @@ int fpga_card_parse(struct fpga_card *c, config_setting_t *cfg)
else
cerror(cfg_slot, "PCI ID must be a string");
}
-
+
cfg_ips = config_setting_get_member(cfg, "ips");
if (!cfg_ips)
cerror(cfg, "FPGA configuration is missing ips section");
@@ -98,53 +98,53 @@ int fpga_card_parse(struct fpga_card *c, config_setting_t *cfg)
config_setting_t *cfg_ip = config_setting_get_elem(cfg_ips, i);
const char *vlnv;
-
+
struct fpga_ip_type *vt;
struct fpga_ip ip = {
.card = c,
.state = STATE_DESTROYED
};
-
+
if (!config_setting_lookup_string(cfg, "vlnv", &vlnv))
cerror(cfg, "FPGA IP core %s is missing the VLNV identifier", c->name);
vt = fpga_ip_type_lookup(vlnv);
if (!vt)
cerror(cfg, "FPGA IP core VLNV identifier '%s' is invalid", vlnv);
-
+
ret = fpga_ip_init(&ip, vt);
if (ret)
error("Failed to initalize FPGA IP core");
-
+
ret = fpga_ip_parse(&ip, cfg_ip);
if (ret)
cerror(cfg_ip, "Failed to parse FPGA IP core");
list_push(&c->ips, memdup(&ip, sizeof(ip)));
}
-
+
c->cfg = cfg;
c->state = STATE_PARSED;
-
+
return 0;
}
int fpga_card_parse_list(struct list *cards, config_setting_t *cfg)
{
int ret;
-
+
if (!config_setting_is_group(cfg))
cerror(cfg, "FPGA configuration section must be a group");
-
+
for (int i = 0; i < config_setting_length(cfg); i++) {
config_setting_t *cfg_fpga = config_setting_get_elem(cfg, i);
-
+
struct fpga_card c;
-
+
ret = fpga_card_parse(&c, cfg_fpga);
if (ret)
cerror(cfg_fpga, "Failed to parse FPGA card configuration");
-
+
list_push(cards, memdup(&c, sizeof(c)));
}
@@ -178,7 +178,7 @@ int fpga_card_start(struct fpga_card *c)
ret = vfio_pci_enable(&c->vfio_device);
if (ret)
serror("Failed to enable PCI device");
-
+
/* Reset system? */
if (c->do_reset) {
/* Reset / detect PCI device */
@@ -210,7 +210,7 @@ int fpga_card_stop(struct fpga_card *c)
int ret;
assert(c->state == STATE_STOPPED);
-
+
for (size_t j = 0; j < list_length(&c->ips); j++) {
struct fpga_ip *i = list_at(&c->ips, j);
@@ -218,9 +218,9 @@ int fpga_card_stop(struct fpga_card *c)
if (ret)
error("Failed to stop FPGA IP core: %s (%u)", i->name, ret);
}
-
+
c->state = STATE_STOPPED;
-
+
return 0;
}
@@ -242,7 +242,7 @@ void fpga_card_dump(struct fpga_card *c)
fpga_ip_dump(i);
}
}
-
+
vfio_dump(c->vfio_device.group->container);
}
@@ -260,7 +260,7 @@ int fpga_card_check(struct fpga_card *c)
c->sw = fpga_vlnv_lookup(&c->ips, &(struct fpga_vlnv) { "xilinx.com", "ip", "axis_interconnect", NULL });
if (!c->sw)
warn("FPGA is missing an AXI4-Stream switch");
-
+
return 0;
}
@@ -296,7 +296,7 @@ int fpga_card_reset(struct fpga_card *c)
/* After reset the value should be zero again */
if (rst_reg[0])
return -2;
-
+
c->state = STATE_INITIALIZED;
return 0;
diff --git a/lib/fpga/ip.c b/lib/fpga/ip.c
index 997eb8cc0..b407d6c36 100644
--- a/lib/fpga/ip.c
+++ b/lib/fpga/ip.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -29,9 +29,9 @@
int fpga_ip_init(struct fpga_ip *c, struct fpga_ip_type *vt)
{
int ret;
-
+
assert(c->state == STATE_DESTROYED);
-
+
c->_vt = vt;
c->_vd = alloc(vt->size);
@@ -40,7 +40,7 @@ int fpga_ip_init(struct fpga_ip *c, struct fpga_ip_type *vt)
return ret;
c->state = STATE_INITIALIZED;
-
+
debug(8, "IP Core %s initalized (%u)", c->name, ret);
return ret;
@@ -50,7 +50,7 @@ int fpga_ip_parse(struct fpga_ip *c, config_setting_t *cfg)
{
int ret;
long long baseaddr;
-
+
assert(c->state != STATE_STARTED && c->state != STATE_DESTROYED);
c->cfg = cfg;
@@ -74,7 +74,7 @@ int fpga_ip_parse(struct fpga_ip *c, config_setting_t *cfg)
ret = c->_vt && c->_vt->parse ? c->_vt->parse(c) : 0;
if (ret)
error("Failed to parse settings for IP core '%s'", c->name);
-
+
c->state = STATE_PARSED;
return 0;
@@ -85,13 +85,13 @@ int fpga_ip_start(struct fpga_ip *c)
int ret;
assert(c->state == STATE_CHECKED);
-
+
ret = c->_vt->start ? c->_vt->start(c) : 0;
if (ret)
return ret;
c->state = STATE_STARTED;
-
+
return 0;
}
@@ -100,13 +100,13 @@ int fpga_ip_stop(struct fpga_ip *c)
int ret;
assert(c->state == STATE_STARTED);
-
+
ret = c->_vt->stop ? c->_vt->stop(c) : 0;
if (ret)
return ret;
-
+
c->state = STATE_STOPPED;
-
+
return 0;
}
@@ -115,7 +115,7 @@ int fpga_ip_destroy(struct fpga_ip *c)
int ret;
assert(c->state != STATE_DESTROYED);
-
+
fpga_vlnv_destroy(&c->vlnv);
ret = c->_vt->destroy ? c->_vt->destroy(c) : 0;
@@ -141,7 +141,7 @@ void fpga_ip_dump(struct fpga_ip *c)
assert(c->state != STATE_DESTROYED);
info("IP %s: vlnv=%s:%s:%s:%s baseaddr=%#jx, irq=%d, port=%d",
- c->name, c->vlnv.vendor, c->vlnv.library, c->vlnv.name, c->vlnv.version,
+ c->name, c->vlnv.vendor, c->vlnv.library, c->vlnv.name, c->vlnv.version,
c->baseaddr, c->irq, c->port);
if (c->_vt->dump)
@@ -153,11 +153,11 @@ struct fpga_ip_type * fpga_ip_type_lookup(const char *vstr)
int ret;
struct fpga_vlnv vlnv;
-
+
ret = fpga_vlnv_parse(&vlnv, vstr);
if (ret)
return NULL;
-
+
/* Try to find matching IP type */
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *p = list_at(&plugins, i);
@@ -165,6 +165,6 @@ struct fpga_ip_type * fpga_ip_type_lookup(const char *vstr)
if (p->type == PLUGIN_TYPE_FPGA_IP && !fpga_vlnv_cmp(&vlnv, &p->ip.vlnv))
return &p->ip;
}
-
+
return NULL;
}
diff --git a/lib/fpga/ips/dft.c b/lib/fpga/ips/dft.c
index ff1288d14..c3c1ec809 100644
--- a/lib/fpga/ips/dft.c
+++ b/lib/fpga/ips/dft.c
@@ -18,24 +18,24 @@ int dft_parse(struct fpga_ip *c)
struct dft *dft = c->_vd;
config_setting_t *cfg_harms;
-
+
if (!config_setting_lookup_int(c->cfg, "period", &dft->period))
cerror(c->cfg, "DFT IP core requires 'period' setting");
-
+
if (!config_setting_lookup_int(c->cfg, "decimation", &dft->decimation))
cerror(c->cfg, "DFT IP core requires 'decimation' setting");
cfg_harms = config_setting_get_member(c->cfg, "harmonics");
if (!cfg_harms)
cerror(c->cfg, "DFT IP core requires 'harmonics' setting!");
-
+
if (!config_setting_is_array(cfg_harms))
cerror(c->cfg, "DFT IP core requires 'harmonics' to be an array of integers!");
-
+
dft->num_harmonics = config_setting_length(cfg_harms);
if (dft->num_harmonics <= 0)
cerror(cfg_harms, "DFT IP core requires 'harmonics' to contain at least 1 integer!");
-
+
dft->fharmonics = alloc(sizeof(float) * dft->num_harmonics);
for (int i = 0; i < dft->num_harmonics; i++)
@@ -47,7 +47,7 @@ int dft_parse(struct fpga_ip *c)
int dft_start(struct fpga_ip *c)
{
int ret;
-
+
struct fpga_card *f = c->card;
struct dft *dft = c->_vd;
@@ -66,14 +66,14 @@ int dft_start(struct fpga_ip *c)
error("DFT IP core supports a maximum of %u harmonics", max_harmonics);
XHls_dft_Set_num_harmonics_V(xdft, dft->num_harmonics);
-
+
XHls_dft_Set_decimation_V(xdft, dft->decimation);
memcpy((void *) (uintptr_t) XHls_dft_Get_fharmonics_BaseAddress(xdft), dft->fharmonics, dft->num_harmonics * sizeof(dft->fharmonics[0]));
XHls_dft_EnableAutoRestart(xdft);
XHls_dft_Start(xdft);
-
+
return 0;
}
@@ -84,7 +84,7 @@ int dft_stop(struct fpga_ip *c)
XHls_dft *xdft = &dft->inst;
XHls_dft_DisableAutoRestart(xdft);
-
+
return 0;
}
@@ -96,7 +96,7 @@ int dft_destroy(struct fpga_ip *c)
free(dft->fharmonics);
dft->fharmonics = NULL;
}
-
+
return 0;
}
diff --git a/lib/fpga/ips/dma.c b/lib/fpga/ips/dma.c
index 01deaa31c..b033d6b2c 100644
--- a/lib/fpga/ips/dma.c
+++ b/lib/fpga/ips/dma.c
@@ -38,7 +38,7 @@ int dma_mem_split(struct dma_mem *o, struct dma_mem *a, struct dma_mem *b)
int dma_alloc(struct fpga_ip *c, struct dma_mem *mem, size_t len, int flags)
{
int ret;
-
+
struct fpga_card *f = c->card;
/* Align to next bigger page size chunk */
@@ -63,15 +63,15 @@ int dma_alloc(struct fpga_ip *c, struct dma_mem *mem, size_t len, int flags)
int dma_free(struct fpga_ip *c, struct dma_mem *mem)
{
int ret;
-
+
ret = vfio_unmap_dma(c->card->vfio_device.group->container, (uint64_t) mem->base_virt, (uint64_t) mem->base_phys, mem->len);
if (ret)
return ret;
-
+
ret = munmap(mem->base_virt, mem->len);
if (ret)
return ret;
-
+
return 0;
}
@@ -82,15 +82,15 @@ int dma_ping_pong(struct fpga_ip *c, char *src, char *dst, size_t len)
ret = dma_read(c, dst, len);
if (ret)
return ret;
-
+
ret = dma_write(c, src, len);
if (ret)
return ret;
-
+
ret = dma_write_complete(c, NULL, NULL);
if (ret)
return ret;
-
+
ret = dma_read_complete(c, NULL, NULL);
if (ret)
return ret;
@@ -116,7 +116,7 @@ int dma_read(struct fpga_ip *c, char *buf, size_t len)
struct dma *dma = c->_vd;
XAxiDma *xdma = &dma->inst;
-
+
debug(25, "DMA read: dmac=%s buf=%p len=%#zx", c->name, buf, len);
return xdma->HasSg
@@ -203,7 +203,7 @@ int dma_sg_write(struct fpga_ip *c, char *buf, size_t len)
cr |= XAXIDMA_BD_CTRL_TXSOF_MASK;
if (i == bdcnt - 1)
cr |= XAXIDMA_BD_CTRL_TXEOF_MASK;
-
+
XAxiDma_BdSetCtrl(bd, cr);
XAxiDma_BdSetId(bd, (uintptr_t) buf);
@@ -311,9 +311,9 @@ int dma_sg_write_complete(struct fpga_ip *c, char **buf, size_t *len)
while (!(XAxiDma_IntrGetIrq(xdma, XAXIDMA_DMA_TO_DEVICE) & XAXIDMA_IRQ_IOC_MASK))
intc_wait(c->card->intc, c->irq);
XAxiDma_IntrAckIrq(xdma, XAXIDMA_IRQ_IOC_MASK, XAXIDMA_DMA_TO_DEVICE);
-
+
processed = XAxiDma_BdRingFromHw(ring, XAXIDMA_ALL_BDS, &bds);
-
+
if (len != NULL)
*len = XAxiDma_BdGetActualLength(bds, XAXIDMA_MAX_TRANSFER_LEN);
@@ -354,12 +354,12 @@ int dma_sg_read_complete(struct fpga_ip *c, char **buf, size_t *len)
bd = bds;
for (int i = 0; i < bdcnt; i++) {
recvlen += XAxiDma_BdGetActualLength(bd, ring->MaxTransferLen);
-
+
sr = XAxiDma_BdGetSts(bd);
if (sr & XAXIDMA_BD_STS_RXSOF_MASK)
if (i != 0)
warn("sof not first");
-
+
if (sr & XAXIDMA_BD_STS_RXEOF_MASK)
if (i != bdcnt - 1)
warn("eof not last");
@@ -368,7 +368,7 @@ int dma_sg_read_complete(struct fpga_ip *c, char **buf, size_t *len)
bd = (XAxiDma_Bd *) XAxiDma_BdRingNext(ring, bd);
}
-
+
if (len != NULL)
*len = recvlen;
if (buf != NULL)
@@ -378,7 +378,7 @@ int dma_sg_read_complete(struct fpga_ip *c, char **buf, size_t *len)
ret = XAxiDma_BdRingFree(ring, bdcnt, bds);
if (ret != XST_SUCCESS)
return -3;
-
+
return 0;
}
@@ -398,13 +398,13 @@ int dma_simple_read(struct fpga_ip *c, char *buf, size_t len)
if (!xdma->HasS2Mm)
return -3;
-
+
if (!ring->HasDRE) {
uint32_t mask = xdma->MicroDmaMode ? XAXIDMA_MICROMODE_MIN_BUF_ALIGN : ring->DataWidth - 1;
if ((uintptr_t) buf & mask)
return -4;
}
-
+
if(!(XAxiDma_ReadReg(ring->ChanBase, XAXIDMA_SR_OFFSET) & XAXIDMA_HALTED_MASK)) {
if (XAxiDma_Busy(xdma, XAXIDMA_DEVICE_TO_DMA))
return -5;
@@ -485,7 +485,7 @@ int dma_simple_read_complete(struct fpga_ip *c, char **buf, size_t *len)
int dma_simple_write_complete(struct fpga_ip *c, char **buf, size_t *len)
{
struct dma *dma = c->_vd;
-
+
XAxiDma *xdma = &dma->inst;
XAxiDma_BdRing *ring = XAxiDma_GetTxRing(xdma);
@@ -566,7 +566,7 @@ int dma_start(struct fpga_ip *c)
struct dma *dma = c->_vd;
XAxiDma *xdma = &dma->inst;
-
+
/* Guess DMA type */
sg = (XAxiDma_In32((uintptr_t) c->card->map + c->baseaddr + XAXIDMA_TX_OFFSET+ XAXIDMA_SR_OFFSET) &
XAxiDma_In32((uintptr_t) c->card->map + c->baseaddr + XAXIDMA_RX_OFFSET+ XAXIDMA_SR_OFFSET) & XAXIDMA_SR_SGINCL_MASK) ? 1 : 0;
@@ -588,7 +588,7 @@ int dma_start(struct fpga_ip *c)
.MicroDmaMode = 0,
.AddrWidth = 32
};
-
+
ret = XAxiDma_CfgInitialize(xdma, &xdma_cfg);
if (ret != XST_SUCCESS)
return -1;
@@ -597,7 +597,7 @@ int dma_start(struct fpga_ip *c)
ret = XAxiDma_Selftest(xdma);
if (ret != XST_SUCCESS)
return -2;
-
+
/* Map buffer descriptors */
if (xdma->HasSg) {
ret = dma_alloc(c, &dma->bd, FPGA_DMA_BD_SIZE, 0);
@@ -619,7 +619,7 @@ int dma_start(struct fpga_ip *c)
int dma_reset(struct fpga_ip *c)
{
struct dma *dma = c->_vd;
-
+
XAxiDma_Reset(&dma->inst);
return 0;
diff --git a/lib/fpga/ips/fifo.c b/lib/fpga/ips/fifo.c
index cbcb51303..a298052a7 100644
--- a/lib/fpga/ips/fifo.c
+++ b/lib/fpga/ips/fifo.c
@@ -19,17 +19,17 @@
int fifo_start(struct fpga_ip *c)
{
int ret;
-
+
struct fpga_card *f = c->card;
struct fifo *fifo = c->_vd;
-
+
XLlFifo *xfifo = &fifo->inst;
XLlFifo_Config fifo_cfg = {
.BaseAddress = (uintptr_t) f->map + c->baseaddr,
.Axi4BaseAddress = (uintptr_t) c->card->map + fifo->baseaddr_axi4,
.Datainterface = (fifo->baseaddr_axi4 != -1) ? 1 : 0 /* use AXI4 for Data, AXI4-Lite for control */
};
-
+
ret = XLlFifo_CfgInitialize(xfifo, &fifo_cfg, (uintptr_t) c->card->map + c->baseaddr);
if (ret != XST_SUCCESS)
return -1;
@@ -42,7 +42,7 @@ int fifo_start(struct fpga_ip *c)
int fifo_stop(struct fpga_ip *c)
{
struct fifo *fifo = c->_vd;
-
+
XLlFifo *xfifo = &fifo->inst;
XLlFifo_IntDisable(xfifo, XLLF_INT_RC_MASK); /* Receive complete IRQ */
@@ -84,7 +84,7 @@ ssize_t fifo_read(struct fpga_ip *c, char *buf, size_t len)
/* Get length of next frame */
rxlen = XLlFifo_RxGetLen(xllfifo);
nextlen = MIN(rxlen, len);
-
+
/* Read from FIFO */
XLlFifo_Read(xllfifo, buf, nextlen);
@@ -96,7 +96,7 @@ int fifo_parse(struct fpga_ip *c)
struct fifo *fifo = c->_vd;
int baseaddr_axi4;
-
+
if (config_setting_lookup_int(c->cfg, "baseaddr_axi4", &baseaddr_axi4))
fifo->baseaddr_axi4 = baseaddr_axi4;
else
@@ -108,7 +108,7 @@ int fifo_parse(struct fpga_ip *c)
int fifo_reset(struct fpga_ip *c)
{
struct fifo *fifo = c->_vd;
-
+
XLlFifo_Reset(&fifo->inst);
return 0;
diff --git a/lib/fpga/ips/intc.c b/lib/fpga/ips/intc.c
index 7601a8025..5077e0851 100644
--- a/lib/fpga/ips/intc.c
+++ b/lib/fpga/ips/intc.c
@@ -6,14 +6,14 @@
#include
-#include "config.h"
+#include "config.h"
#include "log.h"
#include "plugin.h"
#include "nodes/fpga.h"
-#include "kernel/vfio.h"
-#include "kernel/kernel.h"
+#include "kernel/vfio.h"
+#include "kernel/kernel.h"
#include "fpga/ip.h"
#include "fpga/card.h"
@@ -57,7 +57,7 @@ int intc_start(struct fpga_ip *c)
XIntc_Out32(base + XIN_MER_OFFSET, XIN_INT_HARDWARE_ENABLE_MASK | XIN_INT_MASTER_ENABLE_MASK);
debug(4, "FPGA: enabled interrupts");
-
+
return 0;
}
@@ -67,7 +67,7 @@ int intc_destroy(struct fpga_ip *c)
struct intc *intc = c->_vd;
vfio_pci_msi_deinit(&f->vfio_device, intc->efds);
-
+
return 0;
}
@@ -85,7 +85,7 @@ int intc_enable(struct fpga_ip *c, uint32_t mask, int flags)
/* Clear pending IRQs */
XIntc_Out32(base + XIN_IAR_OFFSET, mask);
-
+
for (int i = 0; i < intc->num_irqs; i++) {
if (mask & (1 << i))
intc->flags[i] = flags;
@@ -145,7 +145,7 @@ uint64_t intc_wait(struct fpga_ip *c, int irq)
ssize_t ret = read(intc->efds[irq], &cnt, sizeof(cnt));
if (ret != sizeof(cnt))
return 0;
-
+
return cnt;
}
}
diff --git a/lib/fpga/ips/model.c b/lib/fpga/ips/model.c
index f80ff551a..4567dd803 100644
--- a/lib/fpga/ips/model.c
+++ b/lib/fpga/ips/model.c
@@ -29,7 +29,7 @@ static int model_info_destroy(struct model_info *i)
{
free(i->field);
free(i->value);
-
+
return 0;
}
@@ -58,7 +58,7 @@ static int model_xsg_map_parse(uint32_t *map, size_t len, struct list *parameter
uint16_t type = map[j] & 0xFFFF;
uint16_t length = map[j] >> 16;
uint32_t *data = &map[j+1];
-
+
switch (type) {
case XSG_BLOCK_GATEWAY_IN:
case XSG_BLOCK_GATEWAY_OUT:
@@ -73,7 +73,7 @@ static int model_xsg_map_parse(uint32_t *map, size_t len, struct list *parameter
p.direction = type & 0x1;
p.type = (data[0] >> 0) & 0xFF;
p.binpt = (data[0] >> 8) & 0xFF;
-
+
e = list_lookup(parameters, p.name);
if (e)
model_param_update(e, &p);
@@ -86,14 +86,14 @@ static int model_xsg_map_parse(uint32_t *map, size_t len, struct list *parameter
i->field = copy_string(0);
i->value = copy_string((int) ceil((double) (strlen(i->field) + 1) / 4))
-
+
list_push(infos, i);
break;
default:
warn("Unknown block type: %#06x", type);
}
-
+
j += length + 1;
}
@@ -140,7 +140,7 @@ int model_parse(struct fpga_ip *c)
struct model_param p;
config_setting_t *cfg_params, *cfg_param;
-
+
if (strcmp(c->vlnv.library, "hls") == 0)
m->type = MODEL_TYPE_HLS;
else if (strcmp(c->vlnv.library, "sysgen") == 0)
@@ -233,7 +233,7 @@ int model_destroy(struct fpga_ip *c)
if (m->xsg.map != NULL)
free(m->xsg.map);
-
+
return 0;
}
@@ -248,7 +248,7 @@ void model_dump(struct fpga_ip *c)
info("Parameters:");
for (size_t i = 0; i < list_length(&m->parameters); i++) { INDENT
struct model_param *p = list_at(&m->parameters, i);
-
+
if (p->direction == MODEL_PARAM_IN)
info("%#jx: %s (%s) = %.3f %s %u",
p->offset,
@@ -293,7 +293,7 @@ int model_param_read(struct model_param *p, double *v)
case MODEL_PARAM_TYPE_FLOAT:
*v = (double) ptr->flt;
break;
-
+
case MODEL_PARAM_TYPE_BOOLEAN:
*v = (double) ptr->ufix ? 1 : 0;
}
@@ -319,7 +319,7 @@ int model_param_write(struct model_param *p, double v)
case MODEL_PARAM_TYPE_FLOAT:
ptr->flt = (float) v;
break;
-
+
case MODEL_PARAM_TYPE_BOOLEAN:
ptr->bol = (bool) v;
break;
@@ -332,11 +332,11 @@ void model_param_add(struct fpga_ip *c, const char *name, enum model_param_direc
{
struct model *m = c->_vd;
struct model_param *p = alloc(sizeof(struct model_param));
-
+
p->name = strdup(name);
p->type = type;
p->direction = dir;
-
+
list_push(&m->parameters, p);
}
@@ -344,13 +344,13 @@ int model_param_remove(struct fpga_ip *c, const char *name)
{
struct model *m = c->_vd;
struct model_param *p;
-
+
p = list_lookup(&m->parameters, name);
if (!p)
return -1;
-
+
list_remove(&m->parameters, p);
-
+
return 0;
}
diff --git a/lib/fpga/ips/switch.c b/lib/fpga/ips/switch.c
index 2fe2bbea5..20d6c370d 100644
--- a/lib/fpga/ips/switch.c
+++ b/lib/fpga/ips/switch.c
@@ -18,7 +18,7 @@
int switch_start(struct fpga_ip *c)
{
int ret;
-
+
struct fpga_card *f = c->card;
struct sw *sw = c->_vd;
@@ -34,7 +34,7 @@ int switch_start(struct fpga_ip *c)
.MaxNumMI = sw->num_ports,
.MaxNumSI = sw->num_ports
};
-
+
ret = XAxisScr_CfgInitialize(xsw, &sw_cfg, (uintptr_t) c->card->map + c->baseaddr);
if (ret != XST_SUCCESS)
return -1;
@@ -43,7 +43,7 @@ int switch_start(struct fpga_ip *c)
XAxisScr_RegUpdateDisable(xsw);
XAxisScr_MiPortDisableAll(xsw);
XAxisScr_RegUpdateEnable(xsw);
-
+
switch_init_paths(c);
return 0;
@@ -58,14 +58,14 @@ int switch_init_paths(struct fpga_ip *c)
XAxisScr_RegUpdateDisable(xsw);
XAxisScr_MiPortDisableAll(xsw);
-
+
for (size_t i = 0; i < list_length(&sw->paths); i++) {
struct sw_path *p = list_at(&sw->paths, i);
struct fpga_ip *mi, *si;
-
+
mi = list_lookup(&c->card->ips, p->out);
si = list_lookup(&c->card->ips, p->in);
-
+
if (!mi || !si || mi->port == -1 || si->port == -1)
error("Invalid path configuration for FPGA");
@@ -84,7 +84,7 @@ int switch_destroy(struct fpga_ip *c)
struct sw *sw = c->_vd;
list_destroy(&sw->paths, NULL, true);
-
+
return 0;
}
@@ -103,13 +103,13 @@ int switch_parse(struct fpga_ip *c)
cfg_sw = config_setting_get_member(f->cfg, "paths");
if (!cfg_sw)
return 0; /* no switch config available */
-
+
for (int i = 0; i < config_setting_length(cfg_sw); i++) {
cfg_path = config_setting_get_elem(cfg_sw, i);
struct sw_path path;
int reverse;
-
+
if (!config_setting_lookup_bool(cfg_path, "reverse", &reverse))
reverse = 0;
@@ -132,11 +132,11 @@ int switch_parse(struct fpga_ip *c)
const char *tmp = path.in;
path.in = path.out;
path.out = tmp;
-
+
list_push(&sw->paths, memdup(&path, sizeof(path)));
}
}
-
+
return 0;
}
@@ -144,7 +144,7 @@ int switch_connect(struct fpga_ip *c, struct fpga_ip *mi, struct fpga_ip *si)
{
struct sw *sw = c->_vd;
XAxis_Switch *xsw = &sw->inst;
-
+
uint32_t mux, port;
/* Check if theres already something connected */
@@ -166,11 +166,11 @@ int switch_connect(struct fpga_ip *c, struct fpga_ip *mi, struct fpga_ip *si)
XAxisScr_RegUpdateDisable(xsw);
XAxisScr_MiPortEnable(xsw, mi->port, si->port);
XAxisScr_RegUpdateEnable(xsw);
-
+
/* Reset IPs */
/*ip_reset(mi);
ip_reset(si);*/
-
+
debug(8, "FPGA: Switch connected %s (%u) to %s (%u)", mi->name, mi->port, si->name, si->port);
return 0;
diff --git a/lib/fpga/ips/timer.c b/lib/fpga/ips/timer.c
index 21916c089..8a3d4f714 100644
--- a/lib/fpga/ips/timer.c
+++ b/lib/fpga/ips/timer.c
@@ -27,7 +27,7 @@ int timer_start(struct fpga_ip *c)
XTmrCtr_CfgInitialize(xtmr, &xtmr_cfg, (uintptr_t) f->map + c->baseaddr);
XTmrCtr_InitHw(xtmr);
-
+
return 0;
}
diff --git a/lib/fpga/vlnv.c b/lib/fpga/vlnv.c
index 5fdada339..582e42d8f 100644
--- a/lib/fpga/vlnv.c
+++ b/lib/fpga/vlnv.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -47,7 +47,7 @@ int fpga_vlnv_parse(struct fpga_vlnv *c, const char *vlnv)
c->library = strdup(strtok(NULL, ":"));
c->name = strdup(strtok(NULL, ":"));
c->version = strdup(strtok(NULL, ":"));
-
+
free(tmp);
return 0;
@@ -59,6 +59,6 @@ int fpga_vlnv_destroy(struct fpga_vlnv *v)
free(v->library);
free(v->name);
free(v->version);
-
+
return 0;
}
diff --git a/lib/hist.c b/lib/hist.c
index 6b8b0bbd9..4bf1ff3fb 100644
--- a/lib/hist.c
+++ b/lib/hist.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -50,7 +50,7 @@ int hist_init(struct hist *h, double low, double high, double resolution)
}
hist_reset(h);
-
+
return 0;
}
@@ -60,14 +60,14 @@ int hist_destroy(struct hist *h)
free(h->data);
h->data = NULL;
}
-
+
return 0;
}
void hist_put(struct hist *h, double value)
{
int idx = INDEX(h, value);
-
+
h->last = value;
/* Update min/max */
@@ -135,7 +135,7 @@ void hist_print(struct hist *h, int details)
{ INDENT
if (h->length > 0) {
hist_cnt_t missed = h->total - h->higher - h->lower;
-
+
stats("Counted values: %ju (%ju between %f and %f)", h->total, missed, h->low, h->high);
stats("Highest: %f Lowest: %f", h->highest, h->lowest);
stats("Mu: %f Sigma2: %f Sigma: %f", hist_mean(h), hist_var(h), hist_stddev(h));
@@ -182,14 +182,14 @@ void hist_plot(struct hist *h)
char * hist_dump(struct hist *h)
{
char *buf = alloc(128);
-
+
strcatf(&buf, "[ ");
for (int i = 0; i < h->length; i++)
strcatf(&buf, "%ju ", h->data[i]);
strcatf(&buf, "]");
-
+
return buf;
}
@@ -216,7 +216,7 @@ json_t * hist_json(struct hist *h)
for (int i = 0; i < h->length; i++)
json_array_append(json_buckets, json_integer(h->data[i]));
-
+
json_object_set(json_hist, "buckets", json_buckets);
}
@@ -226,11 +226,11 @@ json_t * hist_json(struct hist *h)
int hist_dump_json(struct hist *h, FILE *f)
{
json_t *j = hist_json(h);
-
+
int ret = json_dumpf(j, f, 0);
-
+
json_decref(j);
-
+
return ret;
}
#endif /* WITH_JANNSON */
@@ -248,7 +248,7 @@ int hist_dump_matlab(struct hist *h, FILE *f)
fprintf(f, "'mean', %f, ", hist_mean(h));
fprintf(f, "'variance', %f, ", hist_var(h));
fprintf(f, "'stddev', %f, ", hist_stddev(h));
-
+
if (h->total - h->lower - h->higher > 0) {
char *buf = hist_dump(h);
fprintf(f, "'buckets', %s", buf);
@@ -258,6 +258,6 @@ int hist_dump_matlab(struct hist *h, FILE *f)
fprintf(f, "'buckets', zeros(1, %d)", h->length);
fprintf(f, ")");
-
+
return 0;
}
diff --git a/lib/hook.c b/lib/hook.c
index 9f6c12c48..2df4ec00a 100644
--- a/lib/hook.c
+++ b/lib/hook.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,20 +37,20 @@ int hook_init(struct hook *h, struct hook_type *vt, struct path *p)
int ret;
assert(h->state == STATE_DESTROYED);
-
+
h->priority = vt->priority;
h->path = p;
h->_vt = vt;
h->_vd = alloc(vt->size);
-
+
ret = h->_vt->init ? h->_vt->init(h) : 0;
if (ret)
return ret;
-
+
h->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -67,7 +67,7 @@ int hook_parse(struct hook *h, config_setting_t *cfg)
return ret;
h->state = STATE_PARSED;
-
+
return 0;
}
@@ -76,16 +76,16 @@ int hook_destroy(struct hook *h)
int ret;
assert(h->state != STATE_DESTROYED);
-
+
ret = h->_vt->destroy ? h->_vt->destroy(h) : 0;
if (ret)
return ret;
-
+
if (h->_vd)
free(h->_vd);
-
+
h->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -157,7 +157,7 @@ int hook_cmp_priority(const void *a, const void *b)
{
struct hook *ha = (struct hook *) a;
struct hook *hb = (struct hook *) b;
-
+
return ha->priority - hb->priority;
}
@@ -172,26 +172,26 @@ int hook_parse_list(struct list *list, config_setting_t *cfg, struct path *o)
for (int i = 0; i < config_setting_length(cfg); i++) {
config_setting_t *cfg_hook = config_setting_get_elem(cfg, i);
-
+
const char *name = config_setting_name(cfg_hook);
-
+
p = plugin_lookup(PLUGIN_TYPE_HOOK, name);
if (!p)
continue; /* We ignore all non hook settings in this libconfig object setting */
-
+
if (!config_setting_is_group(cfg_hook))
cerror(cfg_hook, "The 'hooks' setting must be an array of strings.");
-
+
struct hook h = { .state = STATE_DESTROYED };
-
+
ret = hook_init(&h, &p->hook, o);
if (ret)
continue;
-
+
/* If the user does not assign a priority, we will use the
* position of the hook section in the congiguration file. */
h.priority = priority++;
-
+
ret = hook_parse(&h, cfg_hook);
if (ret)
continue;
diff --git a/lib/hooks/convert.c b/lib/hooks/convert.c
index 242ec2251..8e34cf85f 100644
--- a/lib/hooks/convert.c
+++ b/lib/hooks/convert.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -32,7 +32,7 @@ struct convert {
TO_FIXED,
TO_FLOAT
} mode;
-
+
double scale;
long long mask;
@@ -41,7 +41,7 @@ struct convert {
static int convert_init(struct hook *h)
{
struct convert *p = h->_vd;
-
+
p->scale = 1;
p->mask = -1;
@@ -51,9 +51,9 @@ static int convert_init(struct hook *h)
static int convert_parse(struct hook *h, config_setting_t *cfg)
{
struct convert *p = h->_vd;
-
+
const char *mode;
-
+
config_setting_lookup_float(cfg, "scale", &p->scale);
config_setting_lookup_int64(cfg, "mask", &p->mask);
@@ -66,7 +66,7 @@ static int convert_parse(struct hook *h, config_setting_t *cfg)
p->mode = TO_FLOAT;
else
error("Invalid parameter '%s' for hook 'convert'", mode);
-
+
return 0;
}
@@ -76,11 +76,11 @@ static int convert_read(struct hook *h, struct sample *smps[], size_t *cnt)
for (int i = 0; i < *cnt; i++) {
for (int k = 0; k < smps[i]->length; k++) {
-
+
/* Only convert values which are not masked */
if ((k < sizeof(p->mask) * 8) && !(p->mask & (1LL << k)))
continue;
-
+
switch (p->mode) {
case TO_FIXED:
smps[i]->data[k].i = smps[i]->data[k].f * p->scale;
diff --git a/lib/hooks/decimate.c b/lib/hooks/decimate.c
index 1b46e1630..b4d7c9237 100644
--- a/lib/hooks/decimate.c
+++ b/lib/hooks/decimate.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -35,7 +35,7 @@ struct decimate {
static int decimate_init(struct hook *h)
{
struct decimate *p = h->_vd;
-
+
p->counter = 0;
return 0;
@@ -44,7 +44,7 @@ static int decimate_init(struct hook *h)
static int decimate_parse(struct hook *h, config_setting_t *cfg)
{
struct decimate *p = h->_vd;
-
+
if (!cfg)
error("Missing configuration for hook: '%s'", plugin_name(h->_vt));
@@ -57,18 +57,18 @@ static int decimate_parse(struct hook *h, config_setting_t *cfg)
static int decimate_read(struct hook *h, struct sample *smps[], size_t *cnt)
{
struct decimate *p = h->_vd;
-
+
int i, ok;
for (i = 0, ok = 0; i < *cnt; i++) {
if (p->counter++ % p->ratio == 0) {
struct sample *tmp;
-
+
tmp = smps[ok];
smps[ok++] = smps[i];
smps[i] = tmp;
}
}
-
+
*cnt = ok;
return 0;
@@ -88,5 +88,5 @@ static struct plugin p = {
};
REGISTER_PLUGIN(&p)
-
+
/** @} */
\ No newline at end of file
diff --git a/lib/hooks/drop.c b/lib/hooks/drop.c
index ad09c533f..d6ab88012 100644
--- a/lib/hooks/drop.c
+++ b/lib/hooks/drop.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -32,10 +32,10 @@
static int drop_read(struct hook *h, struct sample *smps[], size_t *cnt)
{
int i, ok, dist;
-
+
for (i = 0, ok = 0; i < *cnt; i++) {
h->last = smps[i];
-
+
if (h->prev) {
dist = h->last->sequence - (int32_t) h->prev->sequence;
if (dist <= 0) {
@@ -45,12 +45,12 @@ static int drop_read(struct hook *h, struct sample *smps[], size_t *cnt)
}
else {
struct sample *tmp;
-
+
tmp = smps[i];
smps[i] = smps[ok];
smps[ok++] = tmp;
}
-
+
/* To discard the first X samples in 'smps[]' we must
* shift them to the end of the 'smps[]' array.
* In case the hook returns a number 'ok' which is smaller than 'cnt',
@@ -59,7 +59,7 @@ static int drop_read(struct hook *h, struct sample *smps[], size_t *cnt)
}
else {
struct sample *tmp;
-
+
tmp = smps[i];
smps[i] = smps[ok];
smps[ok++] = tmp;
@@ -69,7 +69,7 @@ static int drop_read(struct hook *h, struct sample *smps[], size_t *cnt)
}
*cnt = ok;
-
+
return 0;
}
diff --git a/lib/hooks/fix_ts.c b/lib/hooks/fix_ts.c
index 273e4a946..9f7249e4e 100644
--- a/lib/hooks/fix_ts.c
+++ b/lib/hooks/fix_ts.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/lib/hooks/jitter_calc.c b/lib/hooks/jitter_calc.c
index 0f8f9b527..f87fcab3a 100644
--- a/lib/hooks/jitter_calc.c
+++ b/lib/hooks/jitter_calc.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -43,7 +43,7 @@ static int curr_count = 0;
*
* Drawbacks: No protection for out of order packets. Default positive delay assumed,
* so GPS timestamp should be earlier than NTP timestamp. If difference b/w NTP and GPS ts
- * is high (i.e. several mins depending on GPS_NTP_DELAY_WIN_SIZE),
+ * is high (i.e. several mins depending on GPS_NTP_DELAY_WIN_SIZE),
* the variance value will overrun the 64bit value.
*/
int hook_jitter_ts(struct hook *h, struct sample *smps[], size_t *cnt)
@@ -58,13 +58,13 @@ int hook_jitter_ts(struct hook *h, struct sample *smps[], size_t *cnt)
/* Calc on microsec instead of nenosec delay as variance formula overflows otherwise.*/
curr_delay_us = delay_sec*1000000 + delay_nsec/1000;
-
+
delay_mov_sum = delay_mov_sum + curr_delay_us - delay_series[curr_count];
moving_avg[curr_count] = delay_mov_sum/(GPS_NTP_DELAY_WIN_SIZE); /* Will be valid after GPS_NTP_DELAY_WIN_SIZE initial values */
-
+
delay_mov_sum_sqrd = delay_mov_sum_sqrd + (curr_delay_us*curr_delay_us) - (delay_series[curr_count]*delay_series[curr_count]);
moving_var[curr_count] = (delay_mov_sum_sqrd - (delay_mov_sum*delay_mov_sum)/GPS_NTP_DELAY_WIN_SIZE)/(GPS_NTP_DELAY_WIN_SIZE-1);
-
+
delay_series[curr_count] = curr_delay_us; /* Update the last delay value */
/* Jitter calc formula as used in Wireshark according to RFC3550 (RTP)
@@ -72,9 +72,9 @@ int hook_jitter_ts(struct hook *h, struct sample *smps[], size_t *cnt)
J(i) = J(i-1)+(|D(i-1,i)|-J(i-1))/16
*/
jitter_val[(curr_count+1)%GPS_NTP_DELAY_WIN_SIZE] = jitter_val[curr_count] + (abs(curr_delay_us) - jitter_val[curr_count])/16;
-
+
info("jitter %ld usec, moving average %ld usec, moving variance %ld usec\n", jitter_val[(curr_count+1)%GPS_NTP_DELAY_WIN_SIZE], moving_avg[curr_count], moving_var[curr_count]);
-
+
curr_count++;
if(curr_count >= GPS_NTP_DELAY_WIN_SIZE)
curr_count = 0;
diff --git a/lib/hooks/map.c b/lib/hooks/map.c
index 9d1429744..434eade3c 100644
--- a/lib/hooks/map.c
+++ b/lib/hooks/map.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -55,11 +55,11 @@ static int map_parse(struct hook *h, config_setting_t *cfg)
int ret;
struct map *p = h->_vd;
config_setting_t *cfg_mapping;
-
+
cfg_mapping = config_setting_lookup(cfg, "mapping");
if (!cfg_mapping || !config_setting_is_array(cfg_mapping))
return -1;
-
+
ret = mapping_parse(&p->mapping, cfg_mapping);
if (ret)
return ret;
@@ -82,7 +82,7 @@ static int map_read(struct hook *h, struct sample *smps[], size_t *cnt)
for (int i = 0; i < *cnt; i++) {
mapping_remap(&p->mapping, smps[i], tmp[i], NULL);
-
+
SWAP(smps[i], tmp[i]);
}
diff --git a/lib/hooks/print.c b/lib/hooks/print.c
index 6fe3faa56..d3040152b 100644
--- a/lib/hooks/print.c
+++ b/lib/hooks/print.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -47,13 +47,13 @@ static int print_init(struct hook *h)
static int print_start(struct hook *h)
{
struct print *p = h->_vd;
-
+
if (p->uri) {
p->output = fopen(p->uri, "w+");
if (!p->output)
error("Failed to open file %s for writing", p->uri);
}
-
+
return 0;
}
@@ -72,7 +72,7 @@ static int print_parse(struct hook *h, config_setting_t *cfg)
struct print *p = h->_vd;
config_setting_lookup_string(cfg, "output", &p->uri);
-
+
return 0;
}
diff --git a/lib/hooks/restart.c b/lib/hooks/restart.c
index 028a52ca8..5f314df2f 100644
--- a/lib/hooks/restart.c
+++ b/lib/hooks/restart.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -44,7 +44,7 @@ static int restart_read(struct hook *h, struct sample *smps[], size_t *cnt)
/* Run restart hooks */
for (size_t i = 0; i < list_length(&h->path->hooks); i++) {
struct hook *k = list_at(&h->path->hooks, i);
-
+
hook_restart(k);
}
}
@@ -52,7 +52,7 @@ static int restart_read(struct hook *h, struct sample *smps[], size_t *cnt)
h->prev = h->last;
}
-
+
return 0;
}
diff --git a/lib/hooks/shift_seq.c b/lib/hooks/shift_seq.c
index 2d10b7180..ad16b4ca5 100644
--- a/lib/hooks/shift_seq.c
+++ b/lib/hooks/shift_seq.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,10 +34,10 @@ struct shift {
static int shift_seq_parse(struct hook *h, config_setting_t *cfg)
{
struct shift *p = h->_vd;
-
+
if (!config_setting_lookup_int(cfg, "offset", &p->offset))
cerror(cfg, "Missing setting 'offset' for hook '%s'", plugin_name(h->_vt));
-
+
return 0;
}
diff --git a/lib/hooks/shift_ts.c b/lib/hooks/shift_ts.c
index 27608539c..cff2e4fc8 100644
--- a/lib/hooks/shift_ts.c
+++ b/lib/hooks/shift_ts.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -40,9 +40,9 @@ struct shift_ts {
static int shift_ts_init(struct hook *h)
{
struct shift_ts *p = h->_vd;
-
+
p->mode = SHIFT_ORIGIN; /* Default mode */
-
+
return 0;
}
@@ -62,20 +62,20 @@ static int shift_ts_parse(struct hook *h, config_setting_t *cfg)
else
cerror(cfg, "Invalid mode parameter '%s' for hook '%s'", mode, plugin_name(h->_vt));
}
-
+
double offset;
if (!config_setting_lookup_float(cfg, "offset", &offset))
cerror(cfg, "Missing setting 'offset' for hook '%s'", plugin_name(h->_vt));
-
+
p->offset = time_from_double(offset);
-
+
return 0;
}
static int shift_ts_read(struct hook *h, struct sample *smps[], size_t *cnt)
{
struct shift_ts *p = h->_vd;
-
+
for (int i = 0; i < *cnt; i++) {
struct sample *s = smps[i];
struct timespec *ts;
@@ -86,7 +86,7 @@ static int shift_ts_read(struct hook *h, struct sample *smps[], size_t *cnt)
case SHIFT_SENT: ts = &s->ts.sent; break;
default: return -1;
}
-
+
*ts = time_add(ts, &p->offset); break;
}
diff --git a/lib/hooks/skip_first.c b/lib/hooks/skip_first.c
index 190ef2fb9..6ff5504b9 100644
--- a/lib/hooks/skip_first.c
+++ b/lib/hooks/skip_first.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -67,7 +67,7 @@ static int skip_first_parse(struct hook *h, config_setting_t *cfg)
}
else
cerror(cfg, "Missing setting 'seconds' or 'samples' for hook '%s'", plugin_name(h->_vt));
-
+
return 0;
}
@@ -76,7 +76,7 @@ static int skip_first_restart(struct hook *h)
struct skip_first *p = h->_vd;
p->state = HOOK_SKIP_FIRST_STATE_STARTED;
-
+
return 0;
}
@@ -90,12 +90,12 @@ static int skip_first_read(struct hook *h, struct sample *smps[], size_t *cnt)
case HOOK_SKIP_MODE_SAMPLES:
p->samples.until = smps[0]->sequence + p->samples.wait;
break;
-
+
case HOOK_SKIP_MODE_SECONDS:
p->seconds.until = time_add(&smps[0]->ts.origin, &p->seconds.wait);
break;
}
-
+
p->state = HOOK_SKIP_FIRST_STATE_SKIPPING;
}
@@ -106,15 +106,15 @@ static int skip_first_read(struct hook *h, struct sample *smps[], size_t *cnt)
case HOOK_SKIP_MODE_SAMPLES:
skip = p->samples.until > smps[i]->sequence;
break;
-
+
case HOOK_SKIP_MODE_SECONDS:
skip = time_delta(&p->seconds.until, &smps[i]->ts.origin) < 0;
break;
default:
skip = false;
- break;
+ break;
}
-
+
if (!skip) {
struct sample *tmp;
@@ -129,7 +129,7 @@ static int skip_first_read(struct hook *h, struct sample *smps[], size_t *cnt)
* only the first 'ok' samples in 'smps[]' are accepted and further processed.
*/
}
-
+
*cnt = ok;
return 0;
@@ -150,5 +150,5 @@ static struct plugin p = {
};
REGISTER_PLUGIN(&p)
-
+
/** @} */
\ No newline at end of file
diff --git a/lib/hooks/stats_collect.c b/lib/hooks/stats_collect.c
index 02d1fe17f..fa2e6e028 100644
--- a/lib/hooks/stats_collect.c
+++ b/lib/hooks/stats_collect.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@ struct stats_collect {
enum stats_format format;
int verbose;
-
+
FILE *output;
const char *uri;
};
@@ -50,47 +50,47 @@ static int stats_collect_init(struct hook *h)
* This allows the path code to update statistics. */
if (h->path)
h->path->stats = &p->stats;
-
+
/* Set default values */
p->format = STATS_FORMAT_HUMAN;
p->verbose = 0;
p->uri = NULL;
p->output = stdout;
-
+
return 0;
}
static int stats_collect_destroy(struct hook *h)
{
struct stats_collect *p = h->_vd;
-
+
stats_destroy(&p->stats);
-
+
return 0;
}
static int stats_collect_start(struct hook *h)
{
struct stats_collect *p = h->_vd;
-
+
if (p->uri) {
p->output = fopen(p->uri, "w+");
if (!p->output)
error("Failed to open file %s for writing", p->uri);
}
-
+
return 0;
}
static int stats_collect_stop(struct hook *h)
{
struct stats_collect *p = h->_vd;
-
+
stats_print(&p->stats, p->output, p->format, p->verbose);
if (p->uri)
fclose(p->output);
-
+
return 0;
}
@@ -99,7 +99,7 @@ static int stats_collect_restart(struct hook *h)
struct stats_collect *p = h->_vd;
stats_reset(&p->stats);
-
+
return 0;
}
@@ -108,7 +108,7 @@ static int stats_collect_periodic(struct hook *h)
struct stats_collect *p = h->_vd;
stats_print_periodic(&p->stats, p->output, p->format, p->verbose, h->path);
-
+
return 0;
}
@@ -127,20 +127,20 @@ static int stats_collect_parse(struct hook *h, config_setting_t *cfg)
else
cerror(cfg, "Invalid statistic output format: %s", format);
}
-
+
config_setting_lookup_int(cfg, "verbose", &p->verbose);
config_setting_lookup_string(cfg, "output", &p->uri);
-
+
return 0;
}
static int stats_collect_read(struct hook *h, struct sample *smps[], size_t *cnt)
{
struct stats_collect *p = h->_vd;
-
+
stats_collect(p->stats.delta, smps, *cnt);
stats_commit(&p->stats, p->stats.delta);
-
+
return 0;
}
diff --git a/lib/hooks/stats_send.c b/lib/hooks/stats_send.c
index b8ab998d2..698abc526 100644
--- a/lib/hooks/stats_send.c
+++ b/lib/hooks/stats_send.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -46,7 +46,7 @@ static int stats_send_init(struct hook *h)
p->decimation = 1;
p->mode = STATS_SEND_MODE_PERIODIC;
-
+
return 0;
}
@@ -86,7 +86,7 @@ static int stats_send_start(struct hook *h)
if (p->dest->state != STATE_STOPPED)
node_start(p->dest);
-
+
return 0;
}
@@ -96,14 +96,14 @@ static int stats_send_stop(struct hook *h)
if (p->dest->state != STATE_STOPPED)
node_stop(p->dest);
-
+
return 0;
}
static int stats_send_periodic(struct hook *h)
{
struct stats_send *p = h->_vd;
-
+
if (p->mode == STATS_SEND_MODE_PERIODIC)
stats_send(h->path->stats, p->dest);
@@ -121,7 +121,7 @@ static int stats_send_read(struct hook *h, struct sample *smps[], size_t *cnt)
if (processed % p->decimation == 0)
stats_send(h->path->stats, p->dest);
}
-
+
return 0;
}
@@ -142,5 +142,5 @@ static struct plugin p = {
};
REGISTER_PLUGIN(&p)
-
+
/** @} */
\ No newline at end of file
diff --git a/lib/hooks/ts.c b/lib/hooks/ts.c
index 801a71a9d..704e942bf 100644
--- a/lib/hooks/ts.c
+++ b/lib/hooks/ts.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -48,5 +48,5 @@ static struct plugin p = {
};
REGISTER_PLUGIN(&p)
-
+
/** @} */
\ No newline at end of file
diff --git a/lib/json.c b/lib/json.c
index 92e323a1a..022ac0943 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@ static int json_to_config_type(int type)
case JSON_FALSE:
case JSON_NULL: return CONFIG_TYPE_BOOL;
}
-
+
return -1;
}
@@ -50,16 +50,16 @@ json_t * config_to_json(config_setting_t *cfg)
case CONFIG_TYPE_ARRAY:
case CONFIG_TYPE_LIST: {
json_t *json = json_array();
-
+
for (int i = 0; i < config_setting_length(cfg); i++)
json_array_append_new(json, config_to_json(config_setting_get_elem(cfg, i)));
-
+
return json;
}
-
+
case CONFIG_TYPE_GROUP: {
json_t *json = json_object();
-
+
for (int i = 0; i < config_setting_length(cfg); i++) {
json_object_set_new(json,
config_setting_name(config_setting_get_elem(cfg, i)),
@@ -79,12 +79,12 @@ int json_to_config(json_t *json, config_setting_t *parent)
{
config_setting_t *cfg;
int ret, type;
-
+
if (config_setting_is_root(parent)) {
if (!json_is_object(json))
return -1; /* The root must be an object! */
}
-
+
switch (json_typeof(json)) {
case JSON_OBJECT: {
const char *key;
@@ -92,7 +92,7 @@ int json_to_config(json_t *json, config_setting_t *parent)
json_object_foreach(json, key, json_value) {
type = json_to_config_type(json_typeof(json_value));
-
+
cfg = config_setting_add(parent, key, type);
ret = json_to_config(json_value, cfg);
if (ret)
@@ -100,14 +100,14 @@ int json_to_config(json_t *json, config_setting_t *parent)
}
break;
}
-
+
case JSON_ARRAY: {
size_t i;
json_t *json_value;
json_array_foreach(json, i, json_value) {
type = json_to_config_type(json_typeof(json_value));
-
+
cfg = config_setting_add(parent, NULL, type);
ret = json_to_config(json_value, cfg);
if (ret)
@@ -115,11 +115,11 @@ int json_to_config(json_t *json, config_setting_t *parent)
}
break;
}
-
+
case JSON_STRING:
config_setting_set_string(parent, json_string_value(json));
break;
-
+
case JSON_INTEGER:
config_setting_set_int64(parent, json_integer_value(json));
break;
@@ -134,7 +134,7 @@ int json_to_config(json_t *json, config_setting_t *parent)
config_setting_set_bool(parent, json_is_true(json));
break;
}
-
+
return 0;
}
@@ -142,15 +142,15 @@ int sample_io_json_pack(json_t **j, struct sample *s, int flags)
{
json_error_t err;
json_t *json_data = json_array();
-
+
for (int i = 0; i < s->length; i++) {
json_t *json_value = sample_get_data_format(s, i)
? json_integer(s->data[i].i)
: json_real(s->data[i].f);
-
+
json_array_append(json_data, json_value);
}
-
+
*j = json_pack_ex(&err, 0, "{ s: { s: [ I, I ], s: [ I, I ], s: [ I, I ] }, s: I, s: o }",
"ts",
"origin", s->ts.origin.tv_sec, s->ts.origin.tv_nsec,
@@ -158,10 +158,10 @@ int sample_io_json_pack(json_t **j, struct sample *s, int flags)
"sent", s->ts.sent.tv_sec, s->ts.sent.tv_nsec,
"sequence", s->sequence,
"data", json_data);
-
+
if (!*j)
return -1;
-
+
return 0;
}
@@ -169,7 +169,7 @@ int sample_io_json_unpack(json_t *j, struct sample *s, int *flags)
{
int ret, i;
json_t *json_data, *json_value;
-
+
ret = json_unpack(j, "{ s: { s: [ I, I ], s: [ I, I ], s: [ I, I ] }, s: I, s: o }",
"ts",
"origin", &s->ts.origin.tv_sec, &s->ts.origin.tv_nsec,
@@ -177,10 +177,10 @@ int sample_io_json_unpack(json_t *j, struct sample *s, int *flags)
"sent", &s->ts.sent.tv_sec, &s->ts.sent.tv_nsec,
"sequence", &s->sequence,
"data", &json_data);
-
+
if (ret)
return ret;
-
+
s->length = 0;
json_array_foreach(json_data, i, json_value) {
@@ -198,7 +198,7 @@ int sample_io_json_unpack(json_t *j, struct sample *s, int *flags)
default:
return -1;
}
-
+
s->length++;
}
@@ -209,15 +209,15 @@ int sample_io_json_fprint(FILE *f, struct sample *s, int flags)
{
int ret;
json_t *json;
-
+
ret = sample_io_json_pack(&json, s, flags);
if (ret)
return ret;
-
+
ret = json_dumpf(json, f, 0);
-
+
json_decref(json);
-
+
return ret;
}
@@ -230,10 +230,10 @@ int sample_io_json_fscan(FILE *f, struct sample *s, int *flags)
json = json_loadf(f, JSON_DISABLE_EOF_CHECK, &err);
if (!json)
return -1;
-
+
ret = sample_io_json_unpack(json, s, flags);
-
+
json_decref(json);
-
+
return ret;
}
diff --git a/lib/kernel/if.c b/lib/kernel/if.c
index 5dd863420..13528f703 100644
--- a/lib/kernel/if.c
+++ b/lib/kernel/if.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -57,11 +57,11 @@ int if_destroy(struct interface *i)
{
/* List members are freed by the nodes they belong to. */
list_destroy(&i->sockets, NULL, false);
-
+
rtnl_qdisc_put(i->tc_qdisc);
free(i);
-
+
return 0;
}
@@ -138,30 +138,30 @@ int if_get_egress(struct sockaddr *sa, struct rtnl_link **link)
case AF_INET6: {
struct sockaddr_in *sin = (struct sockaddr_in *) sa;
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
-
+
struct nl_addr *addr = (sa->sa_family == AF_INET)
? nl_addr_build(sin->sin_family, &sin->sin_addr.s_addr, sizeof(sin->sin_addr.s_addr))
: nl_addr_build(sin6->sin6_family, sin6->sin6_addr.s6_addr, sizeof(sin6->sin6_addr));
-
+
ifindex = nl_get_egress(addr); nl_addr_put(addr);
if (ifindex < 0)
error("Netlink error: %s", nl_geterror(ifindex));
break;
}
-
+
case AF_PACKET: {
struct sockaddr_ll *sll = (struct sockaddr_ll *) sa;
-
+
ifindex = sll->sll_ifindex;
break;
}
}
-
+
struct nl_cache *cache = nl_cache_mngt_require("route/link");
*link = rtnl_link_get(cache, ifindex);
if (!*link)
return -1;
-
+
return 0;
}
diff --git a/lib/kernel/kernel.c b/lib/kernel/kernel.c
index 0e8845b09..cb07bd727 100644
--- a/lib/kernel/kernel.c
+++ b/lib/kernel/kernel.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,7 +45,7 @@ int kernel_module_set_param(const char *module, const char *param, const char *v
f = fopen(fn, "w");
if (!f)
serror("Failed set parameter %s for kernel module %s to %s", module, param, value);
-
+
debug(LOG_KERNEL | 5, "Set parameter %s of kernel module %s to %s", module, param, value);
fprintf(f, "%s", value);
fclose(f);
@@ -56,7 +56,7 @@ int kernel_module_set_param(const char *module, const char *param, const char *v
int kernel_module_load(const char *module)
{
int ret;
-
+
ret = kernel_module_loaded(module);
if (!ret) {
debug(LOG_KERNEL | 5, "Kernel module %s already loaded...", module);
@@ -124,7 +124,7 @@ int kernel_get_cmdline_param(const char *param, char *buf, size_t len)
FILE *f = fopen(PROCFS_PATH "/cmdline", "r");
if (!f)
return -1;
-
+
if (!fgets(cmdline, sizeof(cmdline), f))
goto out;
@@ -171,22 +171,22 @@ int kernel_get_hugepage_size()
int sz = -1;
size_t len = 0;
FILE *f;
-
+
f = fopen(PROCFS_PATH "/meminfo", "r");
if (!f)
return -1;
-
+
while (getline(&line, &len, f) != -1) {
key = strtok(line, ": ");
value = strtok(NULL, " ");
unit = strtok(NULL, "\n");
-
+
if (!strcmp(key, "Hugepagesize") && !strcmp(unit, "kB")) {
sz = strtoul(value, NULL, 10) * 1024;
break;
}
}
-
+
free(line);
fclose(f);
@@ -197,17 +197,17 @@ int kernel_get_nr_hugepages()
{
FILE *f;
int nr, ret;
-
+
f = fopen(PROCFS_PATH "/sys/vm/nr_hugepages", "r");
if (!f)
serror("Failed to open %s", PROCFS_PATH "/sys/vm/nr_hugepages");
-
+
ret = fscanf(f, "%d", &nr);
if (ret != 1)
nr = -1;
-
+
fclose(f);
-
+
return nr;
}
@@ -218,10 +218,10 @@ int kernel_set_nr_hugepages(int nr)
f = fopen(PROCFS_PATH "/sys/vm/nr_hugepages", "w");
if (!f)
serror("Failed to open %s", PROCFS_PATH "/sys/vm/nr_hugepages");
-
+
fprintf(f, "%d\n", nr);
fclose(f);
-
+
return 0;
}
@@ -232,7 +232,7 @@ int kernel_has_cap(cap_value_t cap)
cap_t caps;
cap_flag_value_t value;
-
+
caps = cap_get_proc();
if (caps == NULL)
return -1;
@@ -240,15 +240,15 @@ int kernel_has_cap(cap_value_t cap)
ret = cap_get_proc(caps);
if (ret == -1)
return -1;
-
+
ret = cap_get_flag(caps, cap, CAP_EFFECTIVE, &value);
if (ret == -1)
return -1;
-
- ret = cap_free(caps);
+
+ ret = cap_free(caps);
if (ret)
return -1;
-
+
return value == CAP_SET ? 0 : -1;
}
#endif
@@ -258,9 +258,9 @@ int kernel_irq_setaffinity(unsigned irq, uintmax_t new, uintmax_t *old)
char fn[64];
FILE *f;
int ret = 0;
-
+
snprintf(fn, sizeof(fn), "/proc/irq/%u/smp_affinity", irq);
-
+
f = fopen(fn, "w+");
if (!f)
return -1; /* IRQ does not exist */
diff --git a/lib/kernel/nl.c b/lib/kernel/nl.c
index 4cb3091b7..433ff8e77 100644
--- a/lib/kernel/nl.c
+++ b/lib/kernel/nl.c
@@ -12,12 +12,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -47,7 +47,7 @@ struct nl_sock * nl_init()
ret = nl_connect(sock, NETLINK_ROUTE);
if (ret)
error("Failed to connect to kernel: %s", nl_geterror(ret));
-
+
/* Fill some caches */
struct nl_cache *cache;
ret = rtnl_link_alloc_cache(sock, AF_UNSPEC, &cache);
@@ -56,7 +56,7 @@ struct nl_sock * nl_init()
nl_cache_mngt_provide(cache);
}
-
+
return sock;
}
@@ -64,7 +64,7 @@ void nl_shutdown()
{
nl_close(sock);
nl_socket_free(sock);
-
+
sock = NULL;
}
@@ -74,7 +74,7 @@ static int egress_cb(struct nl_msg *msg, void *arg)
if (rtnl_route_parse(nlmsg_hdr(msg), route))
return NL_SKIP;
-
+
return NL_STOP;
}
@@ -85,13 +85,13 @@ int nl_get_egress(struct nl_addr *addr)
struct nl_cb *cb;
struct nl_msg *msg = nlmsg_alloc_simple(RTM_GETROUTE, 0);
struct rtnl_route *route = NULL;
-
- /* Build message */
+
+ /* Build message */
struct rtmsg rmsg = {
.rtm_family = nl_addr_get_family(addr),
.rtm_dst_len = nl_addr_get_prefixlen(addr),
};
-
+
ret = nlmsg_append(msg, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO);
if (ret)
goto out;
@@ -104,26 +104,26 @@ int nl_get_egress(struct nl_addr *addr)
ret = nl_send_auto(sock, msg);
if (ret < 0)
goto out;
-
+
/* Hook into receive chain */
cb = nl_cb_alloc(NL_CB_CUSTOM);
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, egress_cb, &route);
-
+
/* Receive message */
nl_recvmsgs_report(sock, cb);
nl_wait_for_ack(sock);
-
+
/* Check result */
if (!route || rtnl_route_get_nnexthops(route) != 1) {
ret = -1;
goto out2;
}
-
+
ret = rtnl_route_nh_get_ifindex(rtnl_route_nexthop_n(route, 0));
rtnl_route_put(route);
-out2: nl_cb_put(cb);
+out2: nl_cb_put(cb);
out: nlmsg_free(msg);
return ret;
diff --git a/lib/kernel/pci.c b/lib/kernel/pci.c
index 177e5bb7a..f981201ad 100644
--- a/lib/kernel/pci.c
+++ b/lib/kernel/pci.c
@@ -22,7 +22,7 @@ int pci_init(struct pci *p)
FILE *f;
char path[256];
int ret;
-
+
snprintf(path, sizeof(path), "%s/bus/pci/devices", SYSFS_PATH);
dp = opendir(path);
@@ -33,20 +33,20 @@ int pci_init(struct pci *p)
while ((entry = readdir(dp))) {
struct pci_device d;
-
+
struct { const char *s; int *p; } map[] = {
{ "vendor", &d.id.vendor },
{ "device", &d.id.device }
};
-
+
/* Read vendor & device id */
for (int i = 0; i < 2; i++) {
snprintf(path, sizeof(path), "%s/bus/pci/devices/%s/%s", SYSFS_PATH, entry->d_name, map[i].s);
-
+
f = fopen(path, "r");
if (!f)
serror("Failed to open '%s'", path);
-
+
ret = fscanf(f, "%x", map[i].p);
if (ret != 1)
error("Failed to parse %s ID from: %s", map[i].s, path);
@@ -58,19 +58,19 @@ int pci_init(struct pci *p)
ret = sscanf(entry->d_name, "%4x:%2x:%2x.%u", &d.slot.domain, &d.slot.bus, &d.slot.device, &d.slot.function);
if (ret != 4)
error("Failed to parse PCI slot number: %s", entry->d_name);
-
+
list_push(&p->devices, memdup(&d, sizeof(d)));
}
closedir(dp);
-
+
return 0;
}
int pci_destroy(struct pci *p)
{
list_destroy(&p->devices, NULL, true);
-
+
return 0;
}
@@ -103,21 +103,21 @@ int pci_device_parse_slot(struct pci_device *f, const char *s, const char **erro
}
else
bus = str;
-
+
if (bus[0] && strcmp(bus, "*")) {
long int x = strtol(bus, &e, 16);
if ((e && *e) || (x < 0 || x > 0xff)) {
*error = "Invalid bus number";
goto fail;
}
-
+
f->slot.bus = x;
}
}
if (dot)
*dot++ = 0;
-
+
if (mid[0] && strcmp(mid, "*")) {
long int x = strtol(mid, &e, 16);
@@ -128,10 +128,10 @@ int pci_device_parse_slot(struct pci_device *f, const char *s, const char **erro
f->slot.device = x;
}
-
+
if (dot && dot[0] && strcmp(dot, "*")) {
long int x = strtol(dot, &e, 16);
-
+
if ((e && *e) || (x < 0 || x > 7)) {
*error = "Invalid function number";
goto fail;
@@ -139,7 +139,7 @@ int pci_device_parse_slot(struct pci_device *f, const char *s, const char **erro
f->slot.function = x;
}
-
+
free(str);
return 0;
@@ -165,7 +165,7 @@ int pci_device_parse_id(struct pci_device *f, const char *str, const char **erro
*s++ = 0;
if (str[0] && strcmp(str, "*")) {
long int x = strtol(str, &e, 16);
-
+
if ((e && *e) || (x < 0 || x > 0xffff)) {
*error = "Invalid vendor ID";
goto fail;
@@ -184,13 +184,13 @@ int pci_device_parse_id(struct pci_device *f, const char *str, const char **erro
*error = "Invalid device ID";
goto fail;
}
-
+
f->id.device = x;
}
-
+
if (c && c[0] && strcmp(s, "*")) {
long int x = strtol(c, &e, 16);
-
+
if ((e && *e) || (x < 0 || x > 0xffff)) {
*error = "Invalid class code";
goto fail;
@@ -217,7 +217,7 @@ int pci_device_compare(const struct pci_device *d, const struct pci_device *f)
if ((f->id.device >= 0 && f->id.device != d->id.device) || (f->id.vendor >= 0 && f->id.vendor != d->id.vendor))
return 0;
}
-
+
if (f->id.class >= 0) {
if (f->id.class != d->id.class)
return 0;
diff --git a/lib/kernel/rt.c b/lib/kernel/rt.c
index e837c990e..23929d4ed 100644
--- a/lib/kernel/rt.c
+++ b/lib/kernel/rt.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -33,9 +33,9 @@
int rt_init(int priority, int affinity)
{
info("Initialize real-time sub-system");
-
+
{ INDENT
-
+
int is_rt;
/* Use FIFO scheduler with real time priority */
@@ -52,7 +52,7 @@ int rt_init(int priority, int affinity)
rt_set_affinity(affinity);
else
warn("You should use the 'affinity' setting to pin VILLASnode to dedicate CPU cores");
-
+
}
return 0;
@@ -82,7 +82,7 @@ int rt_set_affinity(int affinity)
CPU_XOR(&cset_non_isol, &cset_isol, &cset_pin);
if (CPU_COUNT(&cset_non_isol) > 0) {
char isol[128], pin[128];
-
+
cpulist_create(isol, sizeof(isol), &cset_isol);
cpulist_create(pin, sizeof(pin), &cset_pin);
@@ -98,7 +98,7 @@ int rt_set_affinity(int affinity)
serror("Failed to set CPU affinity to %s", list);
debug(LOG_KERNEL | 3, "Set affinity to %s", list);
-
+
return 0;
}
@@ -114,7 +114,7 @@ int rt_set_priority(int priority)
serror("Failed to set real time priority");
debug(LOG_KERNEL | 3, "Task priority set to %u", priority);
-
+
return 0;
}
diff --git a/lib/kernel/tc.c b/lib/kernel/tc.c
index 1d113b4fb..a1e2f0e33 100644
--- a/lib/kernel/tc.c
+++ b/lib/kernel/tc.c
@@ -12,12 +12,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -39,7 +39,7 @@ int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **netem)
{
const char *str;
int val;
-
+
struct rtnl_qdisc *ne = rtnl_qdisc_alloc();
if (!ne)
error("Failed to allocated memory!");
@@ -50,7 +50,7 @@ int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **netem)
if (rtnl_netem_set_delay_distribution(ne, str))
cerror(cfg, "Invalid delay distribution '%s' in netem config", str);
}
-
+
if (config_setting_lookup_int(cfg, "limit", &val)) {
if (val <= 0)
cerror(cfg, "Invalid value '%d' for limit setting", val);
@@ -77,7 +77,7 @@ int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **netem)
if (config_setting_lookup_int(cfg, "loss", &val)) {
if (val < 0 || val > 100)
cerror(cfg, "Invalid percentage value '%d' for loss setting", val);
-
+
rtnl_netem_set_loss(ne, val);
}
@@ -91,7 +91,7 @@ int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **netem)
if (config_setting_lookup_int(cfg, "corruption", &val)) {
if (val < 0 || val > 100)
cerror(cfg, "Invalid percentage value '%d' for corruption setting", val);
-
+
rtnl_netem_set_corruption_probability(ne, val);
}
@@ -103,49 +103,49 @@ int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **netem)
char * tc_print(struct rtnl_qdisc *ne)
{
char *buf = NULL;
-
+
if (rtnl_netem_get_limit(ne) > 0)
strcatf(&buf, "limit %upkts", rtnl_netem_get_limit(ne));
if (rtnl_netem_get_delay(ne) > 0) {
strcatf(&buf, "delay %.2fms ", rtnl_netem_get_delay(ne) / 1000.0);
-
+
if (rtnl_netem_get_jitter(ne) > 0) {
strcatf(&buf, "jitter %.2fms ", rtnl_netem_get_jitter(ne) / 1000.0);
-
+
if (rtnl_netem_get_delay_correlation(ne) > 0)
strcatf(&buf, "%u%% ", rtnl_netem_get_delay_correlation(ne));
}
}
-
+
if (rtnl_netem_get_loss(ne) > 0) {
strcatf(&buf, "loss %u%% ", rtnl_netem_get_loss(ne));
-
+
if (rtnl_netem_get_loss_correlation(ne) > 0)
strcatf(&buf, "%u%% ", rtnl_netem_get_loss_correlation(ne));
}
-
+
if (rtnl_netem_get_reorder_probability(ne) > 0) {
strcatf(&buf, " reorder%u%% ", rtnl_netem_get_reorder_probability(ne));
-
+
if (rtnl_netem_get_reorder_correlation(ne) > 0)
strcatf(&buf, "%u%% ", rtnl_netem_get_reorder_correlation(ne));
}
-
+
if (rtnl_netem_get_corruption_probability(ne) > 0) {
strcatf(&buf, "corruption %u%% ", rtnl_netem_get_corruption_probability(ne));
-
+
if (rtnl_netem_get_corruption_correlation(ne) > 0)
strcatf(&buf, "%u%% ", rtnl_netem_get_corruption_correlation(ne));
}
-
+
if (rtnl_netem_get_duplicate(ne) > 0) {
strcatf(&buf, "duplication %u%% ", rtnl_netem_get_duplicate(ne));
-
+
if (rtnl_netem_get_duplicate_correlation(ne) > 0)
strcatf(&buf, "%u%% ", rtnl_netem_get_duplicate_correlation(ne));
}
-
+
return buf;
}
@@ -168,7 +168,7 @@ int tc_prio(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl
rtnl_tc_set_link(TC_CAST(q), i->nl_link);
rtnl_tc_set_parent(TC_CAST(q), parent);
rtnl_tc_set_handle(TC_CAST(q), handle);
- rtnl_tc_set_kind(TC_CAST(q), "prio");
+ rtnl_tc_set_kind(TC_CAST(q), "prio");
rtnl_qdisc_prio_set_bands(q, bands + 3);
rtnl_qdisc_prio_set_priomap(q, map, sizeof(map));
@@ -176,9 +176,9 @@ int tc_prio(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl
ret = rtnl_qdisc_add(sock, q, NLM_F_CREATE | NLM_F_REPLACE);
*qd = q;
-
+
debug(LOG_TC | 3, "Added prio qdisc with %d bands to interface '%s'", bands, rtnl_link_get_name(i->nl_link));
-
+
return ret;
}
@@ -200,9 +200,9 @@ int tc_netem(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hd
ret = rtnl_qdisc_add(sock, q, NLM_F_CREATE);
*qd = q;
-
+
debug(LOG_TC | 3, "Added netem qdisc to interface '%s'", rtnl_link_get_name(i->nl_link));
-
+
return ret;
}
@@ -221,16 +221,16 @@ int tc_mark(struct interface *i, struct rtnl_cls **cls, tc_hdl_t flowid, uint32_
rtnl_tc_set_kind(TC_CAST(c), "fw");
rtnl_cls_set_protocol(c, ETH_P_ALL);
-
+
rtnl_fw_set_classid(c, flowid);
rtnl_fw_set_mask(c, 0xFFFFFFFF);
ret = rtnl_cls_add(sock, c, NLM_F_CREATE);
*cls = c;
-
+
debug(LOG_TC | 3, "Added fwmark classifier with mark %d to interface '%s'", mark, rtnl_link_get_name(i->nl_link));
-
+
return ret;
}
@@ -239,5 +239,5 @@ int tc_reset(struct interface *i)
struct nl_sock *sock = nl_init();
/* We restore the default pfifo_fast qdisc, by deleting ours */
- return rtnl_qdisc_delete(sock, i->tc_qdisc);
+ return rtnl_qdisc_delete(sock, i->tc_qdisc);
}
diff --git a/lib/kernel/vfio.c b/lib/kernel/vfio.c
index 2e8c4e730..2bed71df4 100644
--- a/lib/kernel/vfio.c
+++ b/lib/kernel/vfio.c
@@ -57,7 +57,7 @@ int vfio_get_iommu_name(int index, char *buf, size_t len)
return -1;
int ret = fgets(buf, len, f) == buf ? 0 : -1;
-
+
/* Remove trailing newline */
char *c = strrchr(buf, '\n');
if (c)
@@ -91,7 +91,7 @@ int vfio_group_destroy(struct vfio_group *g)
int ret;
list_destroy(&g->devices, (dtor_cb_t) vfio_device_destroy, false);
-
+
ret = ioctl(g->fd, VFIO_GROUP_UNSET_CONTAINER);
if (ret)
return ret;
@@ -103,7 +103,7 @@ int vfio_group_destroy(struct vfio_group *g)
return ret;
debug(5, "VFIO: closed group: group=%u, fd=%d", g->index, g->fd);
-
+
return 0;
}
@@ -119,10 +119,10 @@ int vfio_device_destroy(struct vfio_device *d)
return ret;
debug(5, "VFIO: closed device: name=%s, fd=%d", d->name, d->fd);
-
+
free(d->mappings);
free(d->name);
-
+
return 0;
}
@@ -133,7 +133,7 @@ int vfio_init(struct vfio_container *v)
/* Initialize datastructures */
memset(v, 0, sizeof(*v));
-
+
list_init(&v->groups);
/* Load VFIO kernel module */
@@ -170,9 +170,9 @@ int vfio_group_attach(struct vfio_group *g, struct vfio_container *c, int index)
g->index = index;
g->container = c;
-
+
list_init(&g->devices);
-
+
/* Open group fd */
snprintf(buf, sizeof(buf), VFIO_DEV("%u"), g->index);
g->fd = open(buf, O_RDWR);
@@ -183,7 +183,7 @@ int vfio_group_attach(struct vfio_group *g, struct vfio_container *c, int index)
ret = ioctl(g->fd, VFIO_GROUP_SET_CONTAINER, &c->fd);
if (ret < 0)
serror("Failed to attach VFIO group to container");
-
+
/* Set IOMMU type */
ret = ioctl(c->fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
if (ret < 0)
@@ -195,10 +195,10 @@ int vfio_group_attach(struct vfio_group *g, struct vfio_container *c, int index)
ret = ioctl(g->fd, VFIO_GROUP_GET_STATUS, &g->status);
if (ret < 0)
serror("Failed to get VFIO group status");
-
+
if (!(g->status.flags & VFIO_GROUP_FLAGS_VIABLE))
error("VFIO group is not available: bind all devices to the VFIO driver!");
-
+
list_push(&c->groups, g);
return 0;
@@ -208,11 +208,11 @@ int vfio_pci_attach(struct vfio_device *d, struct vfio_container *c, struct pci_
{
char name[32];
int ret;
-
+
/* Load PCI bus driver for VFIO */
if (kernel_module_load("vfio_pci"))
error("Failed to load kernel driver: %s", "vfio_pci");
-
+
/* Bind PCI card to vfio-pci driver*/
ret = pci_attach_driver(pdev, "vfio-pci");
if (ret)
@@ -229,7 +229,7 @@ int vfio_pci_attach(struct vfio_device *d, struct vfio_container *c, struct pci_
ret = vfio_device_attach(d, c, name, index);
if (ret < 0)
return ret;
-
+
/* Check if this is really a vfio-pci device */
if (!(d->info.flags & VFIO_DEVICE_FLAGS_PCI)) {
vfio_device_destroy(d);
@@ -245,7 +245,7 @@ int vfio_device_attach(struct vfio_device *d, struct vfio_container *c, const ch
{
int ret;
struct vfio_group *g = NULL;
-
+
/* Check if group already exists */
for (size_t i = 0; i < list_length(&c->groups); i++) {
struct vfio_group *h = list_at(&c->groups, i);
@@ -253,7 +253,7 @@ int vfio_device_attach(struct vfio_device *d, struct vfio_container *c, const ch
if (h->index == index)
g = h;
}
-
+
if (!g) {
g = alloc(sizeof(struct vfio_group));
@@ -261,7 +261,7 @@ int vfio_device_attach(struct vfio_device *d, struct vfio_container *c, const ch
ret = vfio_group_attach(g, c, index);
if (ret)
error("Failed to attach to IOMMU group: %u", index);
-
+
info("Attached new group %u to VFIO container", g->index);
}
@@ -307,7 +307,7 @@ int vfio_device_attach(struct vfio_device *d, struct vfio_container *c, const ch
if (ret < 0)
serror("Failed to get IRQs of VFIO device: %s", d->name);
}
-
+
list_push(&d->group->devices, d);
return 0;
@@ -379,7 +379,7 @@ int vfio_pci_msi_find(struct vfio_device *d, int nos[32])
do {
last = col;
} while ((col = strtok(NULL, " ")));
-
+
ret = sscanf(last, "vfio-msi[%u](%12[0-9:])", &idx, name);
if (ret == 2) {
@@ -395,7 +395,7 @@ int vfio_pci_msi_find(struct vfio_device *d, int nos[32])
int vfio_pci_msi_deinit(struct vfio_device *d, int efds[32])
{
- int ret, irq_setlen, irq_count = d->irqs[VFIO_PCI_MSI_IRQ_INDEX].count;
+ int ret, irq_setlen, irq_count = d->irqs[VFIO_PCI_MSI_IRQ_INDEX].count;
struct vfio_irq_set *irq_set;
/* Check if this is really a vfio-pci device */
@@ -429,9 +429,9 @@ int vfio_pci_msi_deinit(struct vfio_device *d, int efds[32])
int vfio_pci_msi_init(struct vfio_device *d, int efds[32])
{
- int ret, irq_setlen, irq_count = d->irqs[VFIO_PCI_MSI_IRQ_INDEX].count;
+ int ret, irq_setlen, irq_count = d->irqs[VFIO_PCI_MSI_IRQ_INDEX].count;
struct vfio_irq_set *irq_set;
-
+
/* Check if this is really a vfio-pci device */
if (!(d->info.flags & VFIO_DEVICE_FLAGS_PCI))
return -1;
@@ -528,7 +528,7 @@ void vfio_dump(struct vfio_container *v)
region->flags
);
}
-
+
for (int i = 0; i < d->info.num_irqs; i++) { INDENT
struct vfio_irq_info *irq = &d->irqs[i];
@@ -551,7 +551,7 @@ void * vfio_map_region(struct vfio_device *d, int idx)
return MAP_FAILED;
d->mappings[idx] = mmap(NULL, r->size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_32BIT, d->fd, r->offset);
-
+
return d->mappings[idx];
}
@@ -559,16 +559,16 @@ int vfio_unmap_region(struct vfio_device *d, int idx)
{
int ret;
struct vfio_region_info *r = &d->regions[idx];
-
+
if (!d->mappings[idx])
return -1; /* was not mapped */
-
+
debug(3, "VFIO: unmap region %u from device", idx);
-
+
ret = munmap(d->mappings[idx], r->size);
if (ret)
return -2;
-
+
d->mappings[idx] = NULL;
return 0;
@@ -577,12 +577,12 @@ int vfio_unmap_region(struct vfio_device *d, int idx)
int vfio_map_dma(struct vfio_container *c, uint64_t virt, uint64_t phys, size_t len)
{
int ret;
-
+
if (len & 0xFFF) {
len += 0x1000;
len &= ~0xFFF;
}
-
+
/* Super stupid allocator */
if (phys == -1) {
phys = c->iova_next;
@@ -609,17 +609,17 @@ int vfio_map_dma(struct vfio_container *c, uint64_t virt, uint64_t phys, size_t
int vfio_unmap_dma(struct vfio_container *c, uint64_t virt, uint64_t phys, size_t len)
{
int ret;
-
+
struct vfio_iommu_type1_dma_unmap dma_unmap = {
.argsz = sizeof(struct vfio_iommu_type1_dma_unmap),
.flags = 0,
.iova = phys,
.size = len,
};
-
+
ret = ioctl(c->fd, VFIO_IOMMU_UNMAP_DMA, &dma_unmap);
if (ret)
serror("Failed to unmap DMA mapping");
-
+
return 0;
}
diff --git a/lib/list.c b/lib/list.c
index ee1aa01fa..9719ee773 100644
--- a/lib/list.c
+++ b/lib/list.c
@@ -12,12 +12,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -33,7 +33,7 @@ static int cmp_lookup(const void *a, const void *b) {
const struct {
char *name;
} *obj = a;
-
+
return strcmp(obj->name, b);
}
@@ -68,15 +68,15 @@ int list_destroy(struct list *l, dtor_cb_t destructor, bool release)
for (size_t i = 0; i < list_length(l); i++) {
void *p = list_at(l, i);
-
+
if (destructor)
destructor(p);
if (release)
free(p);
}
-
+
free(l->array);
-
+
l->array = NULL;
l->length = -1;
@@ -84,9 +84,9 @@ int list_destroy(struct list *l, dtor_cb_t destructor, bool release)
pthread_mutex_unlock(&l->lock);
pthread_mutex_destroy(&l->lock);
-
+
l->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -95,13 +95,13 @@ void list_push(struct list *l, void *p)
pthread_mutex_lock(&l->lock);
assert(l->state == STATE_INITIALIZED);
-
+
/* Resize array if out of capacity */
if (l->length >= l->capacity) {
l->capacity += LIST_CHUNKSIZE;
l->array = realloc(l->array, l->capacity * sizeof(void *));
}
-
+
l->array[l->length] = p;
l->length++;
@@ -122,7 +122,7 @@ void list_remove(struct list *l, void *p)
else
l->array[i - removed] = l->array[i];
}
-
+
l->length -= removed;
pthread_mutex_unlock(&l->lock);
@@ -134,7 +134,7 @@ void * list_lookup(struct list *l, const char *name)
}
int list_contains(struct list *l, void *p)
-{
+{
return list_count(l, cmp_contains, p);
}
@@ -148,7 +148,7 @@ int list_count(struct list *l, cmp_cb_t cmp, void *ctx)
for (size_t i = 0; i < list_length(l); i++) {
void *e = list_at(l, i);
-
+
if (cmp(e, ctx) == 0)
c++;
}
@@ -165,13 +165,13 @@ void * list_search(struct list *l, cmp_cb_t cmp, void *ctx)
pthread_mutex_lock(&l->lock);
assert(l->state == STATE_INITIALIZED);
-
+
for (size_t i = 0; i < list_length(l); i++) {
e = list_at(l, i);
if (cmp(e, ctx) == 0)
goto out;
}
-
+
e = NULL; /* not found */
out: pthread_mutex_unlock(&l->lock);
diff --git a/lib/log.c b/lib/log.c
index c3cafc7c0..70347f88b 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -65,8 +65,8 @@ static const char *facilities_strs[] = {
"xil", /* LOG_XIL */
"tc", /* LOG_TC */
"if", /* LOG_IF */
-
- /* Node-types */
+
+ /* Node-types */
"socket", /* LOG_SOCKET */
"file", /* LOG_FILE */
"fpga", /* LOG_FPGA */
@@ -88,9 +88,9 @@ int log_init(struct log *l, int level, long facilitites)
l->facilities = facilitites;
l->file = stderr;
l->path = NULL;
-
+
l->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -105,7 +105,7 @@ int log_start(struct log *l)
}
l->state = STATE_STARTED;
-
+
debug(LOG_LOG | 5, "Log sub-system started: level=%d, faciltities=%#lx, path=%s", l->level, l->facilities, l->path);
return 0;
@@ -117,16 +117,16 @@ int log_stop(struct log *l)
if (l->file != stderr && l->file != stdout)
fclose(l->file);
}
-
+
l->state = STATE_STOPPED;
-
+
return 0;
}
int log_destroy(struct log *l)
{
default_log.epoch = l->epoch;
-
+
global_log = NULL;
l->state = STATE_DESTROYED;
@@ -152,7 +152,7 @@ int log_set_facility_expression(struct log *l, const char *expression)
bool negate;
char *copy, *token;
long mask = 0, facilities = 0;
-
+
copy = strdup(expression);
token = strtok(copy, ",");
@@ -178,7 +178,7 @@ int log_set_facility_expression(struct log *l, const char *expression)
goto found;
}
}
-
+
error("Invalid log class '%s'", token);
}
@@ -189,9 +189,9 @@ found: if (negate)
token = strtok(NULL, ",");
}
-
+
l->facilities = facilities;
-
+
free(copy);
return l->facilities;
@@ -210,7 +210,7 @@ void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list ap)
{
struct timespec ts = time_now();
char *buf = alloc(512);
-
+
/* Timestamp */
strcatf(&buf, "%10.3f ", time_delta(&l->epoch, &ts));
@@ -247,11 +247,11 @@ void line()
void debug(long class, const char *fmt, ...)
{
va_list ap;
-
+
struct log *l = global_log ? global_log : &default_log;
-
+
int lvl = class & 0xFF;
- int fac = class & ~0xFF;
+ int fac = class & ~0xFF;
if (((fac == 0) || (fac & l->facilities)) && (lvl <= l->level)) {
va_start(ap, fmt);
@@ -263,9 +263,9 @@ void debug(long class, const char *fmt, ...)
void info(const char *fmt, ...)
{
va_list ap;
-
+
struct log *l = global_log ? global_log : &default_log;
-
+
va_start(ap, fmt);
log_vprint(l, LOG_LVL_INFO, fmt, ap);
va_end(ap);
@@ -274,9 +274,9 @@ void info(const char *fmt, ...)
void warn(const char *fmt, ...)
{
va_list ap;
-
+
struct log *l = global_log ? global_log : &default_log;
-
+
va_start(ap, fmt);
log_vprint(l, LOG_LVL_WARN, fmt, ap);
va_end(ap);
@@ -285,7 +285,7 @@ void warn(const char *fmt, ...)
void stats(const char *fmt, ...)
{
va_list ap;
-
+
struct log *l = global_log ? global_log : &default_log;
va_start(ap, fmt);
@@ -296,9 +296,9 @@ void stats(const char *fmt, ...)
void error(const char *fmt, ...)
{
va_list ap;
-
+
struct log *l = global_log ? global_log : &default_log;
-
+
va_start(ap, fmt);
log_vprint(l, LOG_LVL_ERROR, fmt, ap);
va_end(ap);
@@ -310,7 +310,7 @@ void serror(const char *fmt, ...)
{
va_list ap;
char *buf = NULL;
-
+
struct log *l = global_log ? global_log : &default_log;
va_start(ap, fmt);
@@ -318,7 +318,7 @@ void serror(const char *fmt, ...)
va_end(ap);
log_print(l, LOG_LVL_ERROR, "%s: %m (%u)", buf, errno);
-
+
free(buf);
die();
}
diff --git a/lib/log_config.c b/lib/log_config.c
index 83a2c2e41..1d00cf256 100644
--- a/lib/log_config.c
+++ b/lib/log_config.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -31,7 +31,7 @@
int log_parse(struct log *l, config_setting_t *cfg)
{
const char *facilities;
-
+
if (!config_setting_is_group(cfg))
cerror(cfg, "Setting 'log' must be a group.");
@@ -52,13 +52,13 @@ void cerror(config_setting_t *cfg, const char *fmt, ...)
char *buf = NULL;
const char *file;
int line;
-
+
struct log *l = global_log ? global_log : &default_log;
va_start(ap, fmt);
vstrcatf(&buf, fmt, ap);
va_end(ap);
-
+
line = config_setting_source_line(cfg);
file = config_setting_source_file(cfg);
if (!file)
diff --git a/lib/mapping.c b/lib/mapping.c
index 3508b290d..8dcc7280c 100644
--- a/lib/mapping.c
+++ b/lib/mapping.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -31,7 +31,7 @@
int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
{
char *cpy, *type, *field, *subfield, *end;
-
+
cpy = strdup(str);
if (!cpy)
return -1;
@@ -43,15 +43,15 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
if (!strcmp(type, "stats")) {
e->type = MAPPING_TYPE_STATS;
e->length = 1;
-
+
field = strtok(NULL, ".");
if (!field)
goto invalid_format;
-
+
subfield = strtok(NULL, ".");
if (!subfield)
goto invalid_format;
-
+
end = strtok(NULL, ".");
if (end)
goto invalid_format;
@@ -59,7 +59,7 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
e->stats.id = stats_lookup_id(field);
if (e->stats.id < 0)
goto invalid_format;
-
+
if (!strcmp(subfield, "total"))
e->stats.type = MAPPING_STATS_TYPE_TOTAL;
else if (!strcmp(subfield, "last"))
@@ -80,15 +80,15 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
else if (!strcmp(type, "hdr")) {
e->type = MAPPING_TYPE_HEADER;
e->length = 1;
-
+
field = strtok(NULL, ".");
if (!field)
goto invalid_format;
-
+
end = strtok(NULL, ".");
if (end)
goto invalid_format;
-
+
if (!strcmp(field, "sequence"))
e->header.id = MAPPING_HEADER_SEQUENCE;
else if (!strcmp(field, "length"))
@@ -107,7 +107,7 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
end = strtok(NULL, ".");
if (end)
goto invalid_format;
-
+
if (!strcmp(field, "origin"))
e->timestamp.id = MAPPING_TIMESTAMP_ORIGIN;
else if (!strcmp(field, "received"))
@@ -118,32 +118,32 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
else if (!strcmp(type, "data")) {
char *first_str, *last_str, *endptr;
int first, last;
-
+
e->type = MAPPING_TYPE_DATA;
-
+
first_str = strtok(NULL, "-]");
if (!first_str)
goto invalid_format;
-
+
last_str = strtok(NULL, "]");
if (!last_str)
last_str = first_str; /* single element: data[5] => data[5-5] */
-
+
end = strtok(NULL, ".");
if (end)
goto invalid_format;
-
+
first = strtoul(first_str, &endptr, 10);
if (endptr != first_str + strlen(first_str))
goto invalid_format;
-
+
last = strtoul(last_str, &endptr, 10);
if (endptr != last_str + strlen(last_str))
goto invalid_format;
-
+
if (last < first)
goto invalid_format;
-
+
e->data.offset = first;
e->length = last - first + 1;
}
@@ -154,7 +154,7 @@ int mapping_entry_parse_str(struct mapping_entry *e, const char *str)
return 0;
invalid_format:
-
+
free(cpy);
return -1;
}
@@ -166,38 +166,38 @@ int mapping_entry_parse(struct mapping_entry *e, config_setting_t *cfg)
str = config_setting_get_string(cfg);
if (!str)
return -1;
-
+
return mapping_entry_parse_str(e, str);
}
int mapping_init(struct mapping *m)
{
assert(m->state == STATE_DESTROYED);
-
+
list_init(&m->entries);
-
+
m->state = STATE_INITIALIZED;
-
+
return 0;
}
int mapping_destroy(struct mapping *m)
{
assert(m->state != STATE_DESTROYED);
-
+
list_destroy(&m->entries, NULL, true);
-
+
m->state = STATE_DESTROYED;
-
+
return 0;
}
int mapping_parse(struct mapping *m, config_setting_t *cfg)
{
int ret;
-
+
assert(m->state == STATE_INITIALIZED);
-
+
if (!config_setting_is_array(cfg))
return -1;
@@ -206,29 +206,29 @@ int mapping_parse(struct mapping *m, config_setting_t *cfg)
for (int i = 0; i < config_setting_length(cfg); i++) {
struct mapping_entry e;
config_setting_t *cfg_mapping;
-
+
cfg_mapping = config_setting_get_elem(cfg, i);
if (!cfg_mapping)
return -1;
-
+
ret = mapping_entry_parse(&e, cfg_mapping);
if (ret)
- return ret;
-
+ return ret;
+
list_push(&m->entries, memdup(&e, sizeof(e)));
-
+
m->real_length += e.length;
}
-
+
m->state = STATE_PARSED;
-
+
return 0;
}
int mapping_remap(struct mapping *m, struct sample *original, struct sample *remapped, struct stats *s)
{
int k = 0;
-
+
if (remapped->capacity < m->real_length)
return -1;
@@ -246,7 +246,7 @@ int mapping_remap(struct mapping *m, struct sample *original, struct sample *rem
switch (e->type) {
case MAPPING_TYPE_STATS: {
struct hist *h = &s->histograms[e->stats.id];
-
+
switch (e->stats.type) {
case MAPPING_STATS_TYPE_TOTAL:
sample_set_data_format(remapped, k, SAMPLE_DATA_FORMAT_INT);
@@ -277,7 +277,7 @@ int mapping_remap(struct mapping *m, struct sample *original, struct sample *rem
case MAPPING_TYPE_TIMESTAMP: {
struct timespec *ts;
-
+
switch (e->timestamp.id) {
case MAPPING_TIMESTAMP_RECEIVED:
ts = &original->ts.received;
@@ -288,19 +288,19 @@ int mapping_remap(struct mapping *m, struct sample *original, struct sample *rem
default:
return -1;
}
-
+
sample_set_data_format(remapped, k, SAMPLE_DATA_FORMAT_INT);
sample_set_data_format(remapped, k+1, SAMPLE_DATA_FORMAT_INT);
remapped->data[k++].i = ts->tv_sec;
remapped->data[k++].i = ts->tv_nsec;
-
+
break;
}
case MAPPING_TYPE_HEADER:
sample_set_data_format(remapped, k, SAMPLE_DATA_FORMAT_INT);
-
+
switch (e->header.id) {
case MAPPING_HEADER_LENGTH:
remapped->data[k++].i = original->length;
@@ -312,11 +312,11 @@ int mapping_remap(struct mapping *m, struct sample *original, struct sample *rem
return -1;
}
break;
-
+
case MAPPING_TYPE_DATA:
for (int j = e->data.offset; j < e->length + e->data.offset; j++) {
int f = sample_get_data_format(original, j);
-
+
if (j >= original->length) {
sample_set_data_format(remapped, k, SAMPLE_DATA_FORMAT_FLOAT);
remapped->data[k++].f = 0;
@@ -328,7 +328,7 @@ int mapping_remap(struct mapping *m, struct sample *original, struct sample *rem
}
break;
}
-
+
remapped->length += e->length;
}
diff --git a/lib/memory.c b/lib/memory.c
index f6af80ff7..10983fff7 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -43,13 +43,13 @@ int memory_init(int hugepages)
struct rlimit l;
info("Initialize memory sub-system");
-
+
pagecnt = kernel_get_nr_hugepages();
if (pagecnt < hugepages) { INDENT
kernel_set_nr_hugepages(hugepages);
debug(LOG_MEM | 2, "Reserved %d hugepages (was %d)", hugepages, pagecnt);
}
-
+
pagesz = kernel_get_hugepage_size();
if (pagesz < 0)
return -1;
@@ -57,15 +57,15 @@ int memory_init(int hugepages)
ret = getrlimit(RLIMIT_MEMLOCK, &l);
if (ret)
return ret;
-
+
if (l.rlim_cur < pagesz * pagecnt) { INDENT
l.rlim_cur = pagesz * pagecnt;
l.rlim_max = l.rlim_cur;
-
+
ret = setrlimit(RLIMIT_MEMLOCK, &l);
if (ret)
return ret;
-
+
debug(LOG_MEM | 2, "Increased ressource limit of locked memory to %d bytes", pagesz * pagecnt);
}
#endif
@@ -75,7 +75,7 @@ int memory_init(int hugepages)
void * memory_alloc(struct memtype *m, size_t len)
{
void *ptr = m->alloc(m, len, sizeof(void *));
-
+
debug(LOG_MEM | 5, "Allocated %#zx bytes of %s memory: %p", len, m->name, ptr);
return ptr;
@@ -84,7 +84,7 @@ void * memory_alloc(struct memtype *m, size_t len)
void * memory_alloc_aligned(struct memtype *m, size_t len, size_t alignment)
{
void *ptr = m->alloc(m, len, alignment);
-
+
debug(LOG_MEM | 5, "Allocated %#zx bytes of %#zx-byte-aligned %s memory: %p", len, alignment, m->name, ptr);
return ptr;
diff --git a/lib/msg.c b/lib/msg.c
index 4794634f4..b857515b2 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -28,7 +28,7 @@
void msg_ntoh(struct msg *m)
{
msg_hdr_ntoh(m);
-
+
for (int i = 0; i < m->length; i++)
m->data[i].i = ntohl(m->data[i].i);
}
diff --git a/lib/node.c b/lib/node.c
index a6985b221..884393f49 100644
--- a/lib/node.c
+++ b/lib/node.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,12 +37,12 @@ int node_init(struct node *n, struct node_type *vt)
n->_vt = vt;
n->_vd = alloc(vt->size);
-
+
n->id = max_id++;
-
+
/* Default values */
n->vectorize = 1;
-
+
list_push(&vt->instances, n);
n->state = STATE_INITIALIZED;
@@ -57,13 +57,13 @@ int node_parse(struct node *n, config_setting_t *cfg)
int ret;
name = config_setting_name(cfg);
-
+
if (!config_setting_lookup_string(cfg, "type", &type))
cerror(cfg, "Missing node type");
-
+
p = plugin_lookup(PLUGIN_TYPE_NODE, type);
assert(&p->node == n->_vt);
-
+
config_setting_lookup_int(cfg, "vectorize", &n->vectorize);
n->name = name;
@@ -72,7 +72,7 @@ int node_parse(struct node *n, config_setting_t *cfg)
ret = n->_vt->parse ? n->_vt->parse(n, cfg) : 0;
if (ret)
cerror(cfg, "Failed to parse node '%s'", node_name(n));
-
+
n->state = STATE_PARSED;
return ret;
@@ -97,7 +97,7 @@ int node_check(struct node *n)
int node_start(struct node *n)
{
int ret;
-
+
assert(n->state == STATE_CHECKED);
info("Starting node %s", node_name_long(n));
@@ -108,9 +108,9 @@ int node_start(struct node *n)
}
n->state = STATE_STARTED;
-
+
n->sequence = 0;
-
+
return ret;
}
@@ -125,7 +125,7 @@ int node_stop(struct node *n)
{ INDENT
ret = n->_vt->stop ? n->_vt->stop(n) : 0;
}
-
+
if (ret == 0)
n->state = STATE_STOPPED;
@@ -138,20 +138,20 @@ int node_destroy(struct node *n)
if (n->_vt->destroy)
n->_vt->destroy(n);
-
+
list_remove(&n->_vt->instances, n);
if (n->_vd)
free(n->_vd);
-
+
if (n->_name)
free(n->_name);
-
+
if (n->_name_long)
free(n->_name_long);
-
+
n->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -171,10 +171,10 @@ int node_read(struct node *n, struct sample *smps[], unsigned cnt)
else {
nread = n->_vt->read(n, smps, cnt);
}
-
+
for (int i = 0; i < nread; i++)
smps[i]->source = n;
-
+
return nread;
}
@@ -193,7 +193,7 @@ int node_write(struct node *n, struct sample *smps[], unsigned cnt)
else {
nsent = n->_vt->write(n, smps, cnt);
}
-
+
return nsent;
}
@@ -201,7 +201,7 @@ char * node_name(struct node *n)
{
if (!n->_name)
strcatf(&n->_name, RED("%s") "(" YEL("%s") ")", n->name, plugin_name(n->_vt));
-
+
return n->_name;
}
@@ -215,9 +215,9 @@ char * node_name_long(struct node *n)
free(name_long);
}
else
- n->_name_long = node_name(n);
+ n->_name_long = node_name(n);
}
-
+
return n->_name_long;
}
@@ -253,7 +253,7 @@ int node_parse_list(struct list *list, config_setting_t *cfg, struct list *all)
case CONFIG_TYPE_ARRAY:
for (int i = 0; i < config_setting_length(cfg); i++) {
config_setting_t *elm = config_setting_get_elem(cfg, i);
-
+
str = config_setting_get_string(elm);
if (str) {
node = list_lookup(all, str);
diff --git a/lib/node_type.c b/lib/node_type.c
index 4cee70ad8..b4fb095e4 100644
--- a/lib/node_type.c
+++ b/lib/node_type.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -32,14 +32,14 @@
int node_type_start(struct node_type *vt, struct super_node *sn)
{
int ret;
-
+
if (vt->state != STATE_DESTROYED)
return 0;
info("Initializing " YEL("%s") " node type which is used by %zu nodes", plugin_name(vt), list_length(&vt->instances));
{ INDENT
ret = vt->init ? vt->init(sn) : 0;
- }
+ }
if (ret == 0)
vt->state = STATE_STARTED;
@@ -50,7 +50,7 @@ int node_type_start(struct node_type *vt, struct super_node *sn)
int node_type_stop(struct node_type *vt)
{
int ret;
-
+
if (vt->state != STATE_STARTED)
return 0;
@@ -58,7 +58,7 @@ int node_type_stop(struct node_type *vt)
{ INDENT
ret = vt->deinit ? vt->deinit() : 0;
}
-
+
if (ret == 0)
vt->state = STATE_DESTROYED;
diff --git a/lib/nodes/cbuilder.c b/lib/nodes/cbuilder.c
index 7910840e1..93ca31d38 100644
--- a/lib/nodes/cbuilder.c
+++ b/lib/nodes/cbuilder.c
@@ -20,14 +20,14 @@ int cbuilder_parse(struct node *n, config_setting_t *cfg)
if (!config_setting_lookup_float(cfg, "timestep", &cb->timestep))
cerror(cfg, "CBuilder model requires 'timestep' setting");
-
+
if (!config_setting_lookup_string(cfg, "model", &model))
cerror(cfg, "CBuilder model requires 'model' setting");
-
+
cb->model = (struct cbuilder_model *) plugin_lookup(PLUGIN_TYPE_MODEL_CBUILDER, model);
if (!cb->model)
cerror(cfg, "Unknown model '%s'", model);
-
+
cfg_params = config_setting_get_member(cfg, "parameters");
if (cfg_params) {
if (!config_setting_is_array(cfg_params))
@@ -35,7 +35,7 @@ int cbuilder_parse(struct node *n, config_setting_t *cfg)
cb->paramlen = config_setting_length(cfg_params);
cb->params = alloc(cb->paramlen * sizeof(double));
-
+
for (int i = 0; i < cb->paramlen; i++)
cb->params[i] = config_setting_get_float_elem(cfg_params, i);
}
@@ -68,7 +68,7 @@ int cbuilder_start(struct node *n)
int cbuilder_stop(struct node *n)
{
struct cbuilder *cb = n->_vd;
-
+
pthread_mutex_destroy(&cb->mtx);
pthread_cond_destroy(&cb->cv);
@@ -99,7 +99,7 @@ int cbuilder_write(struct node *n, struct sample *smps[], unsigned cnt)
{
struct cbuilder *cb = n->_vd;
struct sample *smp = smps[0];
-
+
pthread_mutex_lock(&cb->mtx);
cb->model->write(&smp->data[0].f, smp->length);
diff --git a/lib/nodes/file.c b/lib/nodes/file.c
index fd55c71b1..3478fb02b 100644
--- a/lib/nodes/file.c
+++ b/lib/nodes/file.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@ int file_reverse(struct node *n)
{
struct file *f = n->_vd;
struct file_direction tmp;
-
+
tmp = f->read;
f->read = f->write;
f->write = tmp;
@@ -46,7 +46,7 @@ static char * file_format_name(const char *format, struct timespec *ts)
{
struct tm tm;
char *buf = alloc(FILE_MAX_PATHLEN);
-
+
/* Convert time */
gmtime_r(&ts->tv_sec, &tm);
@@ -79,10 +79,10 @@ static int file_parse_direction(config_setting_t *cfg, struct file *f, int d)
int file_parse(struct node *n, config_setting_t *cfg)
{
struct file *f = n->_vd;
-
+
config_setting_t *cfg_in, *cfg_out;
-
- cfg_out = config_setting_get_member(cfg, "out");
+
+ cfg_out = config_setting_get_member(cfg, "out");
if (cfg_out) {
if (file_parse_direction(cfg_out, f, FILE_WRITE))
cerror(cfg_out, "Failed to parse output file for node %s", node_name(n));
@@ -98,11 +98,11 @@ int file_parse(struct node *n, config_setting_t *cfg)
f->rewind = 0;
if (!config_setting_lookup_float(cfg_in, "rate", &f->read_rate))
f->read_rate = 0; /* Disable fixed rate sending. Using timestamps of file instead */
-
+
double epoch_flt;
if (!config_setting_lookup_float(cfg_in, "epoch", &epoch_flt))
epoch_flt = 0;
-
+
f->read_epoch = time_from_double(epoch_flt);
const char *epoch_mode;
@@ -132,7 +132,7 @@ char * file_print(struct node *n)
{
struct file *f = n->_vd;
char *buf = NULL;
-
+
if (f->read.fmt) {
const char *epoch_str = NULL;
switch (f->read_epoch_mode) {
@@ -142,30 +142,30 @@ char * file_print(struct node *n)
case EPOCH_ABSOLUTE: epoch_str = "absolute"; break;
case EPOCH_ORIGINAL: epoch_str = "original"; break;
}
-
+
strcatf(&buf, "in=%s, epoch_mode=%s, epoch=%.2f, ",
f->read.uri ? f->read.uri : f->read.fmt,
epoch_str,
time_to_double(&f->read_epoch)
);
-
+
if (f->read_rate)
strcatf(&buf, "rate=%.1f, ", f->read_rate);
}
-
+
if (f->write.fmt) {
strcatf(&buf, "out=%s, mode=%s, ",
f->write.uri ? f->write.uri : f->write.fmt,
f->write.mode
);
}
-
+
if (f->read_first.tv_sec || f->read_first.tv_nsec)
strcatf(&buf, "first=%.2f, ", time_to_double(&f->read_first));
-
+
if (f->read_offset.tv_sec || f->read_offset.tv_nsec)
strcatf(&buf, "offset=%.2f, ", time_to_double(&f->read_offset));
-
+
if ((f->read_first.tv_sec || f->read_first.tv_nsec) &&
(f->read_offset.tv_sec || f->read_offset.tv_nsec)) {
struct timespec eta, now = time_now();
@@ -176,7 +176,7 @@ char * file_print(struct node *n)
if (eta.tv_sec || eta.tv_nsec)
strcatf(&buf, "eta=%.2f sec, ", time_to_double(&eta));
}
-
+
if (strlen(buf) > 2)
buf[strlen(buf) - 2] = 0;
@@ -186,13 +186,13 @@ char * file_print(struct node *n)
int file_start(struct node *n)
{
struct file *f = n->_vd;
-
+
struct timespec now = time_now();
if (f->read.fmt) {
/* Prepare file name */
f->read.uri = file_format_name(f->read.fmt, &now);
-
+
/* Open file */
f->read.handle = file_reopen(&f->read);
if (!f->read.handle)
@@ -204,7 +204,7 @@ int file_start(struct node *n)
: timerfd_create(CLOCK_REALTIME, 0);
if (f->read_timer < 0)
serror("Failed to create timer");
-
+
/* Get current time */
struct timespec now = time_now();
@@ -213,7 +213,7 @@ int file_start(struct node *n)
int ret = sample_io_villas_fscan(f->read.handle->file, &s, NULL); arewind(f->read.handle);
if (ret < 0)
error("Failed to read first timestamp of node %s", node_name(n));
-
+
f->read_first = s.ts.origin;
/* Set read_offset depending on epoch_mode */
@@ -227,15 +227,15 @@ int file_start(struct node *n)
f->read_offset = now;
f->read_offset = time_add(&f->read_offset, &f->read_epoch);
break;
-
+
case EPOCH_RELATIVE: /* read first value at first + epoch */
f->read_offset = f->read_epoch;
break;
-
+
case EPOCH_ABSOLUTE: /* read first value at f->read_epoch */
f->read_offset = time_diff(&f->read_first, &f->read_epoch);
break;
-
+
default: { }
}
}
@@ -256,7 +256,7 @@ int file_start(struct node *n)
int file_stop(struct node *n)
{
struct file *f = n->_vd;
-
+
free(f->read.uri);
free(f->write.uri);
@@ -297,7 +297,7 @@ retry: values = sample_io_villas_fscan(f->read.handle->file, s, &flags); /* Get
return 0;
}
-
+
if (f->read_epoch_mode == EPOCH_ORIGINAL) {
return 1;
}
@@ -309,7 +309,7 @@ retry: values = sample_io_villas_fscan(f->read.handle->file, s, &flags); /* Get
else { /* Wait with fixed rate delay */
if (timerfd_wait(f->read_timer) == 0)
serror("Failed to wait for timer");
-
+
/* Update timestamp */
s->ts.origin = time_now();
}
diff --git a/lib/nodes/fpga.c b/lib/nodes/fpga.c
index 88da3e7a3..a406e4cb4 100644
--- a/lib/nodes/fpga.c
+++ b/lib/nodes/fpga.c
@@ -26,7 +26,7 @@ static struct vfio_container vc;
void fpga_dump(struct fpga *f)
{
struct fpga_card *c = f->ip->card;
-
+
fpga_card_dump(c);
}
@@ -34,11 +34,11 @@ int fpga_init(struct super_node *sn)
{
int ret;
config_setting_t *cfg, *cfg_fpgas;
-
+
ret = pci_init(&pci);
if (ret)
error("Failed to initialize PCI sub-system");
-
+
ret = vfio_init(&vc);
if (ret)
error("Failed to initiliaze VFIO sub-system");
@@ -48,7 +48,7 @@ int fpga_init(struct super_node *sn)
cfg_fpgas = config_setting_lookup(cfg, "fpgas");
if (!cfg_fpgas)
cerror(cfg, "Config file is missing 'fpgas' section");
-
+
ret = fpga_card_parse_list(&cards, cfg_fpgas);
if (ret)
cerror(cfg, "Failed to parse VILLASfpga config");
@@ -61,13 +61,13 @@ int fpga_deinit()
int ret;
list_destroy(&cards, (dtor_cb_t) fpga_card_destroy, true);
-
+
pci_destroy(&pci);
ret = vfio_destroy(&vc);
if (ret)
error("Failed to deinitialize VFIO sub-system");
-
+
ret = pci_destroy(&pci);
if (ret)
error("Failed to deinitialize PCI sub-system");
@@ -91,14 +91,14 @@ int fpga_parse(struct node *n, config_setting_t *cfg)
f->use_irqs = false;
cpy = strdup(dm); /* strtok can not operate on type const char * */
-
+
card_name = strtok(cpy, ":");
ip_name = strtok(NULL, ":");
card = list_lookup(&cards, card_name);
if (!card)
cerror(cfg, "There is no FPGA card named '%s", card_name);
-
+
ip = list_lookup(&card->ips, ip_name);
if (!ip)
cerror(cfg, "There is no datamover named '%s' on the FPGA card '%s'", ip_name, card_name);
@@ -106,7 +106,7 @@ int fpga_parse(struct node *n, config_setting_t *cfg)
cerror(cfg, "The IP '%s' on FPGA card '%s' is not a datamover", ip_name, card_name);
free(cpy);
-
+
f->ip = ip;
return 0;
@@ -116,7 +116,7 @@ char * fpga_print(struct node *n)
{
struct fpga *f = n->_vd;
struct fpga_card *c = f->ip->card;
-
+
if (f->ip)
return strf("dm=%s (%s:%s:%s:%s) baseaddr=%#jx port=%u slot=%02"PRIx8":%02"PRIx8".%"PRIx8" id=%04"PRIx16":%04"PRIx16,
f->ip->name, f->ip->vlnv.vendor, f->ip->vlnv.library, f->ip->vlnv.name, f->ip->vlnv.version,
@@ -154,10 +154,10 @@ int fpga_start(struct node *n)
case FPGA_IP_TYPE_DM_FIFO:
intc_enable(c->intc, (1 << f->ip->irq), flags); /* MM2S & S2MM */
break;
-
+
default: { }
}
-
+
return 0;
}
@@ -181,7 +181,7 @@ int fpga_stop(struct node *n)
case FPGA_IP_TYPE_DM_FIFO:
if (f->use_irqs)
intc_disable(c->intc, f->ip->irq); /* MM2S & S2MM */
-
+
default: { }
}
@@ -198,7 +198,7 @@ int fpga_read(struct node *n, struct sample *smps[], unsigned cnt)
size_t recvlen;
size_t len = SAMPLE_DATA_LEN(64);
-
+
/* We dont get a sequence no from the FPGA. Lets fake it */
smp->sequence = -1;
smp->ts.origin = time_now();
@@ -209,7 +209,7 @@ int fpga_read(struct node *n, struct sample *smps[], unsigned cnt)
ret = dma_read(f->ip, f->dma.base_phys + 0x800, len);
if (ret)
return ret;
-
+
ret = dma_read_complete(f->ip, NULL, &recvlen);
if (ret)
return ret;
@@ -220,7 +220,7 @@ int fpga_read(struct node *n, struct sample *smps[], unsigned cnt)
return 1;
case FPGA_IP_TYPE_DM_FIFO:
recvlen = fifo_read(f->ip, (char *) smp->data, len);
-
+
smp->length = recvlen / 4;
return 1;
@@ -247,7 +247,7 @@ int fpga_write(struct node *n, struct sample *smps[], unsigned cnt)
ret = dma_write(f->ip, f->dma.base_phys, len);
if (ret)
return ret;
-
+
ret = dma_write_complete(f->ip, NULL, &sentlen);
if (ret)
return ret;
@@ -259,10 +259,10 @@ int fpga_write(struct node *n, struct sample *smps[], unsigned cnt)
sentlen = fifo_write(f->ip, (char *) smp->data, len);
return sentlen / sizeof(smp->data[0]);
break;
-
+
default: { }
}
-
+
return -1;
}
diff --git a/lib/nodes/ngsi.c b/lib/nodes/ngsi.c
index 2297ece43..0581e9e9d 100644
--- a/lib/nodes/ngsi.c
+++ b/lib/nodes/ngsi.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
**********************************************************************************/
@@ -70,10 +70,10 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
"type", i->entity_type,
"isPattern", 0
);
-
+
if (flags & NGSI_ENTITY_ATTRIBUTES) {
json_t *attributes = json_array();
-
+
for (size_t j = 0; j < list_length(&i->mapping); j++) {
struct ngsi_attribute *map = list_at(&i->mapping, j);
@@ -81,7 +81,7 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
"name", map->name,
"type", map->type
);
-
+
if (flags & NGSI_ENTITY_VALUES) { /* Build value vector */
json_t *values = json_array();
for (int k = 0; k < cnt; k++) {
@@ -91,13 +91,13 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
smps[k]->sequence
));
}
-
+
json_object_set(attribute, "value", values);
}
-
+
if (flags & NGSI_ENTITY_METADATA) { /* Create Metadata for attribute */
json_t *metadatas = json_array();
-
+
for (size_t i = 0; i < list_length(&map->metadata); i++) {
struct ngsi_metadata *meta = list_at(&map->metadata, i);
@@ -107,13 +107,13 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
"value", meta->value
));
}
-
+
json_object_set(attribute, "metadatas", metadatas);
}
json_array_append_new(attributes, attribute);
}
-
+
json_object_set(entity, "attributes", attributes);
}
@@ -135,10 +135,10 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
);
if (ret || !json_is_array(attributes))
return -1;
-
+
if (strcmp(id, i->entity_id) || strcmp(type, i->entity_type))
return -2;
-
+
for (int k = 0; k < cnt; k++)
smps[k]->length = json_array_size(attributes);
@@ -155,16 +155,16 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
);
if (ret)
return -3;
-
+
/* Check attribute name and type */
map = list_lookup(&i->mapping, name);
if (!map || strcmp(map->type, type))
return -4;
-
+
/* Check metadata */
if (!json_is_array(metadata))
return -5;
-
+
/* Check number of values */
if (!json_is_array(values) || json_array_size(values) != cnt)
return -6;
@@ -178,11 +178,11 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
char *end;
const char *value, *ts, *seq;
ret = json_unpack(tuple, "[ s, s, s ]", &ts, &value, &seq);
- if (ret)
+ if (ret)
return -8;
-
+
smps[k]->sequence = atoi(seq);
-
+
struct timespec tss = time_from_double(strtod(ts, &end));
if (ts == end)
return -9;
@@ -193,7 +193,7 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
return -10;
}
}
-
+
return cnt;
}
@@ -212,13 +212,13 @@ static int ngsi_parse_mapping(struct list *mapping, config_setting_t *cfg)
struct ngsi_attribute map = {
.index = j
};
-
+
/* Parse Attribute: AttributeName(AttributeType) */
int bytes;
if (sscanf(token, "%m[^(](%m[^)])%n", &map.name, &map.type, &bytes) != 2)
cerror(cfg, "Invalid mapping token: '%s'", token);
- token += bytes;
+ token += bytes;
/* MetadataName(MetadataType)=MetadataValue */
list_init(&map.metadata);
@@ -227,14 +227,14 @@ static int ngsi_parse_mapping(struct list *mapping, config_setting_t *cfg)
list_push(&map.metadata, memdup(&meta, sizeof(meta)));
token += bytes;
}
-
+
/* Static metadata */
struct ngsi_metadata source = {
.name = "source",
.type = "string",
.value = name,
};
-
+
struct ngsi_metadata index = {
.name = "index",
.type = "integer",
@@ -242,9 +242,9 @@ static int ngsi_parse_mapping(struct list *mapping, config_setting_t *cfg)
};
snprintf(index.value, 8, "%u", j);
- list_push(&map.metadata, memdup(&index, sizeof(index)));
+ list_push(&map.metadata, memdup(&index, sizeof(index)));
list_push(&map.metadata, memdup(&source, sizeof(source)));
-
+
list_push(mapping, memdup(&map, sizeof(map)));
}
@@ -254,21 +254,21 @@ static int ngsi_parse_mapping(struct list *mapping, config_setting_t *cfg)
static int ngsi_parse_context_response(json_t *response, int *code, char **reason, json_t **rentity) {
int ret;
char *codestr;
-
+
ret = json_unpack(response, "{ s: [ { s: O, s: { s: s, s: s } } ] }",
"contextResponses",
"contextElement", rentity,
"statusCode",
"code", &codestr,
"reasonPhrase", reason
- );
+ );
if (ret) {
warn("Failed to find NGSI response code");
return ret;
}
-
+
*code = atoi(codestr);
-
+
if (*code != 200)
warn("NGSI response: %s %s", codestr, *reason);
@@ -279,7 +279,7 @@ static size_t ngsi_request_writer(void *contents, size_t size, size_t nmemb, voi
{
size_t realsize = size * nmemb;
struct ngsi_response *mem = (struct ngsi_response *) userp;
-
+
mem->data = realloc(mem->data, mem->len + realsize + 1);
if(mem->data == NULL) /* out of memory! */
error("Not enough memory (realloc returned NULL)");
@@ -301,13 +301,13 @@ static int ngsi_request(CURL *handle, const char *endpoint, const char *operatio
json_error_t err;
snprintf(url, sizeof(url), "%s/v1/%s", endpoint, operation);
-
+
curl_easy_setopt(handle, CURLOPT_URL, url);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ngsi_request_writer);
- curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *) &chunk);
+ curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *) &chunk);
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(post));
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, post);
-
+
debug(LOG_NGSI | 18, "Request to context broker: %s\n%s", url, post);
/* We don't want to leave the handle in an invalid state */
@@ -321,14 +321,14 @@ static int ngsi_request(CURL *handle, const char *endpoint, const char *operatio
}
curl_easy_getinfo(handle, CURLINFO_TOTAL_TIME, &time);
-
+
debug(LOG_NGSI | 16, "Request to context broker completed in %.4f seconds", time);
debug(LOG_NGSI | 17, "Response from context broker:\n%s", chunk.data);
-
+
*response = json_loads(chunk.data, 0, &err);
if (!*response)
warn("Received invalid JSON: %s in %s:%u:%u\n%s", err.text, err.source, err.line, err.column, chunk.data);
-
+
out: free(post);
free(chunk.data);
@@ -346,7 +346,7 @@ static int ngsi_request_context_query(CURL *handle, const char *endpoint, json_t
ret = ngsi_request(handle, endpoint, "queryContext", request, &response);
if (ret)
goto out;
-
+
ret = ngsi_parse_context_response(response, &code, &reason, rentity);
if (ret)
goto out2;
@@ -361,17 +361,17 @@ static int ngsi_request_context_update(CURL *handle, const char *endpoint, const
{
int ret, code;
char *reason;
-
+
json_t *response;
json_t *request = json_pack("{ s: s, s: [ o ] }",
"updateAction", action,
"contextElements", entity
);
-
+
ret = ngsi_request(handle, endpoint, "updateContext", request, &response);
if (ret)
goto out;
-
+
json_t *rentity;
ret = ngsi_parse_context_response(response, &code, &reason, &rentity);
if (ret)
@@ -387,9 +387,9 @@ out: json_decref(request);
int ngsi_init(struct super_node *sn)
{
config_setting_t *cfg;
-
+
cfg = config_root_setting(&sn->cfg);
-
+
const char *tname;
if (config_setting_lookup_string(cfg, "name", &tname)) {
name = strdup(tname);
@@ -398,7 +398,7 @@ int ngsi_init(struct super_node *sn)
name = alloc(128); /** @todo missing free */
gethostname((char *) name, 128);
}
-
+
return curl_global_init(CURL_GLOBAL_ALL);
}
@@ -420,10 +420,10 @@ int ngsi_parse(struct node *n, config_setting_t *cfg)
if (!config_setting_lookup_string(cfg, "endpoint", &i->endpoint))
cerror(cfg, "Missing NGSI endpoint for node %s", node_name(n));
-
+
if (!config_setting_lookup_string(cfg, "entity_id", &i->entity_id))
cerror(cfg, "Missing NGSI entity ID for node %s", node_name(n));
-
+
if (!config_setting_lookup_string(cfg, "entity_type", &i->entity_type))
cerror(cfg, "Missing NGSI entity type for node %s", node_name(n));
@@ -432,7 +432,7 @@ int ngsi_parse(struct node *n, config_setting_t *cfg)
if (!config_setting_lookup_float(cfg, "timeout", &i->timeout))
i->timeout = 1; /* default value */
-
+
if (!config_setting_lookup_float(cfg, "rate", &i->rate))
i->rate = 5; /* default value */
@@ -442,7 +442,7 @@ int ngsi_parse(struct node *n, config_setting_t *cfg)
if (ngsi_parse_mapping(&i->mapping, cfg_mapping))
cerror(cfg_mapping, "Invalid mapping for node %s", node_name(n));
-
+
return 0;
}
@@ -459,7 +459,7 @@ static int ngsi_metadata_destroy(struct ngsi_metadata *meta)
free(meta->value);
free(meta->name);
free(meta->type);
-
+
return 0;
}
@@ -467,18 +467,18 @@ static int ngsi_attribute_destroy(struct ngsi_attribute *attr)
{
free(attr->name);
free(attr->type);
-
+
list_destroy(&attr->metadata, (dtor_cb_t) ngsi_metadata_destroy, true);
-
+
return 0;
}
int ngsi_destroy(struct node *n)
{
struct ngsi *i = n->_vd;
-
+
list_destroy(&i->mapping, (dtor_cb_t) ngsi_attribute_destroy, true);
-
+
return 0;
}
@@ -486,16 +486,16 @@ int ngsi_start(struct node *n)
{
struct ngsi *i = n->_vd;
int ret;
-
+
i->curl = curl_easy_init();
i->headers = NULL;
-
+
if (i->access_token) {
char buf[128];
snprintf(buf, sizeof(buf), "Auth-Token: %s", i->access_token);
i->headers = curl_slist_append(i->headers, buf);
}
-
+
/* Create timer */
if (i->timeout > 1 / i->rate)
warn("Timeout is to large for given rate: %f", i->rate);
@@ -503,24 +503,24 @@ int ngsi_start(struct node *n)
i->tfd = timerfd_create_rate(i->rate);
if (i->tfd < 0)
serror("Failed to create timer");
-
+
i->headers = curl_slist_append(i->headers, "Accept: application/json");
i->headers = curl_slist_append(i->headers, "Content-Type: application/json");
-
+
curl_easy_setopt(i->curl, CURLOPT_SSL_VERIFYPEER, i->ssl_verify);
curl_easy_setopt(i->curl, CURLOPT_TIMEOUT_MS, i->timeout * 1e3);
curl_easy_setopt(i->curl, CURLOPT_HTTPHEADER, i->headers);
curl_easy_setopt(i->curl, CURLOPT_USERAGENT, USER_AGENT);
-
+
/* Create entity and atributes */
- json_t *entity = ngsi_build_entity(i, NULL, 0, NGSI_ENTITY_METADATA);
-
+ json_t *entity = ngsi_build_entity(i, NULL, 0, NGSI_ENTITY_METADATA);
+
ret = ngsi_request_context_update(i->curl, i->endpoint, "APPEND", entity);
if (ret)
error("Failed to create NGSI context for node %s", node_name(n));
-
+
json_decref(entity);
-
+
return ret;
}
@@ -528,17 +528,17 @@ int ngsi_stop(struct node *n)
{
struct ngsi *i = n->_vd;
int ret;
-
+
/* Delete complete entity (not just attributes) */
json_t *entity = ngsi_build_entity(i, NULL, 0, 0);
ret = ngsi_request_context_update(i->curl, i->endpoint, "DELETE", entity);
-
+
json_decref(entity);
-
+
curl_easy_cleanup(i->curl);
curl_slist_free_all(i->headers);
-
+
return ret;
}
@@ -546,21 +546,21 @@ int ngsi_read(struct node *n, struct sample *smps[], unsigned cnt)
{
struct ngsi *i = n->_vd;
int ret;
-
+
if (timerfd_wait(i->tfd) == 0)
perror("Failed to wait for timer");
-
+
json_t *rentity;
json_t *entity = ngsi_build_entity(i, NULL, 0, 0);
ret = ngsi_request_context_query(i->curl, i->endpoint, entity, &rentity);
if (ret)
goto out;
-
+
ret = ngsi_parse_entity(rentity, i, smps, cnt);
if (ret)
goto out2;
-
+
out2: json_decref(rentity);
out: json_decref(entity);
@@ -571,13 +571,13 @@ int ngsi_write(struct node *n, struct sample *smps[], unsigned cnt)
{
struct ngsi *i = n->_vd;
int ret;
-
+
json_t *entity = ngsi_build_entity(i, smps, cnt, NGSI_ENTITY_VALUES);
ret = ngsi_request_context_update(i->curl, i->endpoint, "UPDATE", entity);
-
+
json_decref(entity);
-
+
return ret ? 0 : cnt;
}
diff --git a/lib/nodes/opal.c b/lib/nodes/opal.c
index 497cd5dd9..d278dd3a9 100644
--- a/lib/nodes/opal.c
+++ b/lib/nodes/opal.c
@@ -12,12 +12,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -33,12 +33,12 @@
static char *async_shmem_name; /**< Shared Memory identifiers and size, provided via argv. */
static char *print_shmem_name; /**< Shared Memory identifiers and size, provided via argv. */
static int async_shmem_size; /**< Shared Memory identifiers and size, provided via argv. */
-
+
static int send_icons, recv_icons; /** Number of send blocks used in the running OPAL model. */
static int *send_ids, *recv_ids; /** A dynamically allocated array of SendIDs. */
static Opal_GenAsyncParam_Ctrl params; /** String and Float parameters, provided by the OPAL AsyncProcess block. */
-
+
static pthread_mutex_t lock; /** Big Global Lock for libOpalAsync API */
int opal_init(struct super_node *sn)
@@ -120,7 +120,7 @@ int opal_deinit()
int opal_print_global()
{
debug(LOG_OPAL | 2, "Controller ID: %u", params.controllerID);
-
+
char *sbuf = alloc(send_icons * 5);
char *rbuf = alloc(recv_icons * 5);
@@ -131,7 +131,7 @@ int opal_print_global()
debug(LOG_OPAL | 2, "Send Blocks: %s", sbuf);
debug(LOG_OPAL | 2, "Receive Blocks: %s", rbuf);
-
+
free(sbuf);
free(rbuf);
@@ -204,7 +204,7 @@ int opal_read(struct node *n, struct pool *pool, unsigned cnt)
struct msg *m = &pool[first % poolsize];
double data[MSG_VALUES];
-
+
if (cnt != 1)
error("The OPAL-RT node type does not support combining!");
@@ -268,7 +268,7 @@ int opal_write(struct node *n, struct pool *pool, unsigned cnt)
int state;
int len;
double data[m->length];
-
+
if (cnt != 1)
error("The OPAL-RT node type does not support combining!");
diff --git a/lib/nodes/shmem.c b/lib/nodes/shmem.c
index d4ac65d76..4156f13ec 100644
--- a/lib/nodes/shmem.c
+++ b/lib/nodes/shmem.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -62,7 +62,7 @@ int shmem_parse(struct node *n, config_setting_t *cfg)
const char *elm = config_setting_get_string_elem(exec_cfg, i);
if (!elm)
cerror(exec_cfg, "Invalid format for exec");
-
+
shm->exec[i] = strdup(elm);
}
@@ -77,13 +77,13 @@ int shmem_open(struct node *n)
struct shmem *shm = n->_vd;
int ret;
size_t len;
-
+
shm->fd = shm_open(shm->name, O_RDWR | O_CREAT, 0600);
if (shm->fd < 0)
serror("Opening shared memory object failed");
-
+
len = shmem_total_size(shm->queuelen, shm->queuelen, shm->samplelen);
-
+
ret = ftruncate(shm->fd, len);
if (ret < 0)
serror("Setting size of shared memory object failed");
@@ -161,10 +161,10 @@ int shmem_read(struct node *n, struct sample *smps[], unsigned cnt)
recv = shm->polling ? queue_pull_many(&shm->shared->in.q, (void**) smps, cnt)
: queue_signalled_pull_many(&shm->shared->in.qs, (void**) smps, cnt);
-
+
if (recv <= 0)
return recv;
-
+
/* Check if remote process is still running */
ret = atomic_load_explicit(&shm->shared->ext_stopped, memory_order_relaxed);
if (ret)
@@ -178,7 +178,7 @@ int shmem_write(struct node *n, struct sample *smps[], unsigned cnt)
struct shmem *shm = n->_vd;
struct sample *shared_smps[cnt]; /* Samples need to be copied to the shared pool first */
int avail, pushed, len;
-
+
avail = sample_alloc(&shm->shared->pool, shared_smps, cnt);
if (avail != cnt)
warn("Pool underrun for shmem node %s", shm->name);
@@ -188,15 +188,15 @@ int shmem_write(struct node *n, struct sample *smps[], unsigned cnt)
shared_smps[i]->source = NULL;
shared_smps[i]->sequence = smps[i]->sequence;
shared_smps[i]->ts = smps[i]->ts;
-
+
len = MIN(smps[i]->length, shared_smps[i]->capacity);
if (len != smps[i]->length)
warn("Losing data because of sample capacity mismatch in node %s", node_name(n));
-
+
memcpy(shared_smps[i]->data, smps[i]->data, SAMPLE_DATA_LEN(len));
-
+
shared_smps[i]->length = len;
-
+
sample_get(shared_smps[i]);
}
@@ -206,7 +206,7 @@ int shmem_write(struct node *n, struct sample *smps[], unsigned cnt)
return -1;
}
-
+
pushed = shm->polling ? queue_push_many(&shm->shared->out.q, (void**) shared_smps, avail)
: queue_signalled_push_many(&shm->shared->out.qs, (void**) shared_smps, avail);
@@ -223,13 +223,13 @@ char * shmem_print(struct node *n)
strcatf(&buf, "name=%s, queuelen=%d, samplelen=%d, polling=%s",
shm->name, shm->queuelen, shm->samplelen, shm->polling ? "yes" : "no");
-
+
if (shm->exec) {
strcatf(&buf, ", exec='");
-
+
for (int i = 0; shm->exec[i]; i++)
strcatf(&buf, shm->exec[i+1] ? "%s " : "%s", shm->exec[i]);
-
+
strcatf(&buf, "'");
}
diff --git a/lib/nodes/socket.c b/lib/nodes/socket.c
index f57cccbb8..7b630218e 100644
--- a/lib/nodes/socket.c
+++ b/lib/nodes/socket.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -72,21 +72,21 @@ int socket_init(struct super_node *sn)
/* Search of existing interface with correct ifindex */
struct interface *i;
-
+
for (size_t k = 0; k < list_length(&interfaces); k++) {
i = list_at(&interfaces, k);
-
+
if (rtnl_link_get_ifindex(i->nl_link) == rtnl_link_get_ifindex(link))
goto found;
}
/* If not found, create a new interface */
struct interface j = { .sockets.state = STATE_DESTROYED };
-
+
ret = if_init(&j, link);
if (ret)
continue;
-
+
i = memdup(&j, sizeof(j));
list_push(&interfaces, i);
@@ -106,7 +106,7 @@ int socket_deinit()
{
for (size_t j = 0; j < list_length(&interfaces); j++) {
struct interface *i = list_at(&interfaces, j);
-
+
if_stop(i);
}
@@ -131,7 +131,7 @@ char * socket_print(struct node *n)
case SOCKET_HEADER_FAKE: header = "fake"; break;
case SOCKET_HEADER_DEFAULT: header = "default"; break;
}
-
+
if (s->header == SOCKET_HEADER_DEFAULT)
endian = "auto";
else {
@@ -252,7 +252,7 @@ static int socket_read_none(struct node *n, struct sample *smps[], unsigned cnt)
int iov_len = s->header == SOCKET_HEADER_FAKE ? 2 : 1;
struct iovec iov[iov_len];
struct sample *smp = smps[0];
-
+
if (cnt < 1)
return 0;
@@ -261,11 +261,11 @@ static int socket_read_none(struct node *n, struct sample *smps[], unsigned cnt)
iov[0].iov_base = header;
iov[0].iov_len = sizeof(header);
}
-
+
/* Remaining values are payload */
iov[iov_len-1].iov_base = &smp->data;
iov[iov_len-1].iov_len = SAMPLE_DATA_LEN(smp->capacity);
-
+
struct msghdr mhdr = {
.msg_iov = iov,
.msg_iovlen = iov_len,
@@ -284,13 +284,13 @@ static int socket_read_none(struct node *n, struct sample *smps[], unsigned cnt)
recv(s->sd, NULL, 0, 0); /* empty receive buffer */
return -1;
}
-
+
/* Convert message to host endianess */
for (int i = 0; i < ARRAY_LEN(header); i++)
header[i] = s->endian == SOCKET_ENDIAN_BIG
? be32toh(header[i])
: le32toh(header[i]);
-
+
for (int i = 0; i < bytes / SAMPLE_DATA_LEN(1); i++)
smp->data[i].i = s->endian == SOCKET_ENDIAN_BIG
? be32toh(smp->data[i].i)
@@ -300,7 +300,7 @@ static int socket_read_none(struct node *n, struct sample *smps[], unsigned cnt)
length = (bytes - sizeof(header)) / SAMPLE_DATA_LEN(1);
else
length = bytes / SAMPLE_DATA_LEN(1);
-
+
if (length > smp->capacity) {
warn("Node %s received more values than supported. Dropping %u values", node_name(n), length - smp->capacity);
length = smp->capacity;
@@ -351,7 +351,7 @@ static int socket_read_villas(struct node *n, struct sample *smps[], unsigned cn
int received = 0;
char *ptr = data;
-
+
struct msg *msg = (struct msg *) ptr;
struct sample *smp = smps[received];
@@ -369,7 +369,7 @@ static int socket_read_villas(struct node *n, struct sample *smps[], unsigned cn
smp->ts.origin = MSG_TS(msg);
smp->ts.received.tv_sec = -1;
smp->ts.received.tv_nsec = -1;
-
+
memcpy(smp->data, msg->data, SAMPLE_DATA_LEN(msg->length));
ptr += MSG_LEN(msg->length);
@@ -402,7 +402,7 @@ static int socket_write_none(struct node *n, struct sample *smps[], unsigned cnt
data[1] = smps[i]->ts.origin.tv_sec;
data[2] = smps[i]->ts.origin.tv_nsec;
}
-
+
for (int j = 0; j < smps[i]->length; j++)
data[off + j] = s->endian == SOCKET_ENDIAN_BIG
? htobe32(smps[i]->data[j].i)
@@ -415,7 +415,7 @@ static int socket_write_none(struct node *n, struct sample *smps[], unsigned cnt
sent++;
}
-
+
return sent;
}
@@ -427,23 +427,23 @@ static int socket_write_villas(struct node *n, struct sample *smps[], unsigned c
for (int i = 0; i < cnt; i++)
bytes += MSG_LEN(smps[i]->length);
-
+
char data[bytes], *ptr = data;
-
+
struct msg *msg = (struct msg *) ptr;
for (int i = 0; i < cnt; i++) {
*msg = MSG_INIT(smps[i]->length, smps[i]->sequence);
-
+
msg->ts.sec = smps[i]->ts.origin.tv_sec;
msg->ts.nsec = smps[i]->ts.origin.tv_nsec;
-
+
memcpy(msg->data, smps[i]->data, MSG_DATA_LEN(smps[i]->length));
-
+
msg_hton(msg);
-
+
ptr += MSG_LEN(msg->length);
-
+
msg = (struct msg *) ptr;
}
@@ -463,7 +463,7 @@ int socket_read(struct node *n, struct sample *smps[], unsigned cnt)
case SOCKET_HEADER_NONE:
case SOCKET_HEADER_FAKE:
return socket_read_none(n, smps, cnt);
-
+
case SOCKET_HEADER_DEFAULT:
return socket_read_villas(n, smps, cnt);
}
@@ -479,11 +479,11 @@ int socket_write(struct node *n, struct sample *smps[], unsigned cnt)
case SOCKET_HEADER_NONE:
case SOCKET_HEADER_FAKE:
return socket_write_none(n, smps, cnt);
-
+
case SOCKET_HEADER_DEFAULT:
return socket_write_villas(n, smps, cnt);
}
-
+
return -1;
}
@@ -522,7 +522,7 @@ int socket_parse(struct node *n, config_setting_t *cfg)
else
cerror(cfg, "Invalid application header type '%s' for node %s", hdr, node_name(n));
}
-
+
if (!config_setting_lookup_string(cfg, "endian", &endian))
s->endian = SOCKET_ENDIAN_BIG;
else {
diff --git a/lib/nodes/websocket.c b/lib/nodes/websocket.c
index 373e9af7b..f3de1f00c 100644
--- a/lib/nodes/websocket.c
+++ b/lib/nodes/websocket.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -48,13 +48,13 @@ static char * websocket_connection_name(struct websocket_connection *c)
{
if (!c->_name) {
strcatf(&c->_name, "%s (%s)", c->peer.name, c->peer.ip);
-
+
if (c->node)
strcatf(&c->_name, " for node %s", node_name(c->node));
-
+
strcatf(&c->_name, " in %s mode", c->mode == WEBSOCKET_MODE_CLIENT ? "client" : "server");
}
-
+
return c->_name;
}
@@ -68,7 +68,7 @@ static int websocket_connection_init(struct websocket_connection *c, struct lws
c->state = STATE_INITIALIZED;
c->wsi = wsi;
-
+
if (c->node) {
struct websocket *w = c->node->_vd;
@@ -92,7 +92,7 @@ static int websocket_connection_destroy(struct websocket_connection *c)
return 0;
info("LWS: Connection %s closed", websocket_connection_name(c));
-
+
if (c->node) {
struct websocket *w = c->node->_vd;
list_remove(&w->connections, c);
@@ -102,11 +102,11 @@ static int websocket_connection_destroy(struct websocket_connection *c)
if (c->_name)
free(c->_name);
-
+
ret = queue_destroy(&c->queue);
if (ret)
return ret;
-
+
c->state = STATE_DESTROYED;
c->wsi = NULL;
@@ -116,7 +116,7 @@ static int websocket_connection_destroy(struct websocket_connection *c)
static void websocket_destination_destroy(struct websocket_destination *d)
{
free(d->uri);
-
+
free((char *) d->info.path);
free((char *) d->info.address);
}
@@ -133,18 +133,18 @@ static int websocket_connection_write(struct websocket_connection *c, struct sam
case STATE_STARTED:
for (int i = 0; i < cnt; i++) {
sample_get(smps[i]); /* increase reference count */
-
+
ret = queue_push(&c->queue, (void **) smps[i]);
if (ret != 1)
warn("Queue overrun in websocket connection: %s", websocket_connection_name(c));
}
-
+
lws_callback_on_writable(c->wsi);
break;
-
+
default: { }
}
-
+
return 0;
}
@@ -153,14 +153,14 @@ static void websocket_connection_close(struct websocket_connection *c, struct lw
lws_close_reason(wsi, status, (unsigned char *) reason, strlen(reason));
char *msg = strf("LWS: Closing connection");
-
+
if (c)
msg = strcatf(&msg, " with %s", websocket_connection_name(c));
-
+
msg = strcatf(&msg, ": status=%u, reason=%s", status, reason);
warn(msg);
-
+
free(msg);
}
@@ -168,7 +168,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
{
int ret;
struct websocket_connection *c = user;
-
+
struct webmsg *msg;
struct sample *smp;
@@ -198,7 +198,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
}
else {
char *node = uri + 1;
-
+
/* Search for node whose name matches the URI. */
c->node = list_lookup(&p.node.instances, node);
if (c->node == NULL) {
@@ -206,7 +206,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
return -1;
}
}
-
+
ret = websocket_connection_init(c, wsi);
if (ret)
return -1;
@@ -215,12 +215,12 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
case LWS_CALLBACK_CLOSED:
websocket_connection_destroy(c);
-
+
if (c->mode == WEBSOCKET_MODE_CLIENT)
free(c);
return 0;
-
+
case LWS_CALLBACK_CLIENT_WRITEABLE:
case LWS_CALLBACK_SERVER_WRITEABLE:
if (c->state == STATE_STOPPED) {
@@ -234,21 +234,21 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
}
char *buf = NULL;
-
+
while (queue_pull(&c->queue, (void **) &smp)) {
buf = realloc(buf, LWS_PRE + WEBMSG_LEN(smp->length));
if (!buf)
serror("realloc failed:");
-
+
msg = (struct webmsg *) (buf + LWS_PRE);
-
+
msg->version = WEBMSG_VERSION;
msg->type = WEBMSG_TYPE_DATA;
msg->length = smp->length;
msg->sequence = smp->sequence;
msg->id = smp->source->id;
msg->ts.sec = smp->ts.origin.tv_sec;
- msg->ts.nsec = smp->ts.origin.tv_nsec;
+ msg->ts.nsec = smp->ts.origin.tv_nsec;
memcpy(&msg->data, &smp->data, SAMPLE_DATA_LEN(smp->length));
@@ -265,7 +265,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
if (lws_send_pipe_choked(wsi))
break;
}
-
+
free(buf);
/* There are still samples in the queue */
@@ -287,7 +287,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
}
struct timespec ts_recv = time_now();
-
+
msg = (struct webmsg *) in;
while ((char *) msg + WEBMSG_LEN(msg->length) < (char *) in + len) {
struct node *dest;
@@ -303,19 +303,19 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
for (int i = 0; i < list_length(&p.node.instances); i++) {
struct node *n = list_at(&p.node.instances, i);
-
+
if (n->id == msg->id) {
dest = n;
break;
}
}
-
+
if (!dest) {
warn("Ignoring message due to invalid node id");
goto next;
}
}
-
+
struct websocket *w = dest->_vd;
ret = sample_alloc(&w->pool, &smp, 1);
@@ -323,7 +323,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
warn("Pool underrun for connection: %s", websocket_connection_name(c));
break;
}
-
+
smp->ts.origin = WEBMSG_TS(msg);
smp->ts.received = ts_recv;
@@ -333,9 +333,9 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
smp->length = smp->capacity;
warn("Dropping values for connection: %s", websocket_connection_name(c));
}
-
+
memcpy(&smp->data, &msg->data, SAMPLE_DATA_LEN(smp->length));
-
+
ret = queue_signalled_push(&w->queue, (void **) smp);
if (ret != 1) {
warn("Queue overrun for connection %s", websocket_connection_name(c));
@@ -345,7 +345,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
/* Next message */
next: msg = (struct webmsg *) ((char *) msg + WEBMSG_LEN(msg->length));
}
-
+
return 0;
default:
@@ -356,7 +356,7 @@ next: msg = (struct webmsg *) ((char *) msg + WEBMSG_LEN(msg->length));
int websocket_init(struct super_node *sn)
{
list_init(&connections);
-
+
web = &sn->web;
if (web->state != STATE_STARTED)
@@ -388,30 +388,30 @@ int websocket_start(struct node *n)
{
int ret;
struct websocket *w = n->_vd;
-
+
size_t blocklen = LWS_PRE + WEBMSG_LEN(DEFAULT_WEBSOCKET_SAMPLELEN);
-
+
ret = pool_init(&w->pool, DEFAULT_WEBSOCKET_QUEUELEN, blocklen, &memtype_hugepage);
if (ret)
return ret;
-
+
ret = queue_signalled_init(&w->queue, DEFAULT_WEBSOCKET_QUEUELEN, &memtype_hugepage);
if (ret)
return ret;
for (int i = 0; i < list_length(&w->destinations); i++) {
struct websocket_destination *d = list_at(&w->destinations, i);
-
+
struct websocket_connection *c = alloc(sizeof(struct websocket_connection));
-
+
c->state = STATE_DESTROYED;
c->mode = WEBSOCKET_MODE_CLIENT;
c->node = n;
-
+
d->info.context = web->context;
d->info.vhost = web->vhost;
d->info.userdata = c;
-
+
lws_client_connect_via_info(&d->info);
}
@@ -422,7 +422,7 @@ int websocket_stop(struct node *n)
{
int ret;
struct websocket *w = n->_vd;
-
+
for (size_t i = 0; i < list_length(&w->connections); i++) {
struct websocket_connection *c = list_at(&w->connections, i);
@@ -438,7 +438,7 @@ int websocket_stop(struct node *n)
ret = queue_signalled_destroy(&w->queue);
if (ret)
return ret;
-
+
ret = pool_destroy(&w->pool);
if (ret)
return ret;
@@ -483,7 +483,7 @@ int websocket_write(struct node *n, struct sample *smps[], unsigned cnt)
struct websocket *w = n->_vd;
struct sample *cpys[cnt];
-
+
/* Make copies of all samples */
avail = sample_alloc(&w->pool, cpys, cnt);
if (avail < cnt)
@@ -497,16 +497,16 @@ int websocket_write(struct node *n, struct sample *smps[], unsigned cnt)
for (size_t i = 0; i < list_length(&w->connections); i++) {
struct websocket_connection *c = list_at(&w->connections, i);
-
+
websocket_connection_write(c, cpys, cnt);
}
-
+
for (size_t i = 0; i < list_length(&connections); i++) {
struct websocket_connection *c = list_at(&connections, i);
-
+
websocket_connection_write(c, cpys, cnt);
}
-
+
sample_put_many(cpys, avail);
return cnt;
@@ -525,35 +525,35 @@ int websocket_parse(struct node *n, config_setting_t *cfg)
if (cfg_dests) {
if (!config_setting_is_array(cfg_dests))
cerror(cfg_dests, "The 'destinations' setting must be an array of URLs");
-
+
for (int i = 0; i < config_setting_length(cfg_dests); i++) {
const char *uri, *prot, *ads, *path;
-
+
uri = config_setting_get_string_elem(cfg_dests, i);
if (!uri)
cerror(cfg_dests, "The 'destinations' setting must be an array of URLs");
-
+
struct websocket_destination d;
-
+
memset(&d, 0, sizeof(d));
-
+
d.uri = strdup(uri);
if (!d.uri)
serror("Failed to allocate memory");
-
+
ret = lws_parse_uri(d.uri, &prot, &ads, &d.info.port, &path);
if (ret)
cerror(cfg_dests, "Failed to parse websocket URI: '%s'", uri);
-
+
d.info.ssl_connection = !strcmp(prot, "https");
d.info.address = strdup(ads);
d.info.host = d.info.address;
d.info.origin = d.info.address;
d.info.ietf_version_or_minus_one = -1;
d.info.protocol = "live";
-
+
asprintf((char **) &d.info.path, "/%s", path);
-
+
list_push(&w->destinations, memdup(&d, sizeof(d)));
}
}
@@ -566,9 +566,9 @@ char * websocket_print(struct node *n)
struct websocket *w = n->_vd;
char *buf = NULL;
-
+
buf = strcatf(&buf, "destinations=[ ");
-
+
for (size_t i = 0; i < list_length(&w->destinations); i++) {
struct websocket_destination *d = list_at(&w->destinations, i);
@@ -579,9 +579,9 @@ char * websocket_print(struct node *n)
d->info.path
);
}
-
+
buf = strcatf(&buf, "]");
-
+
return buf;
}
diff --git a/lib/path.c b/lib/path.c
index f6aff6e27..4bfa2ddd2 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,9 +45,9 @@ static void path_read(struct path *p)
int enqueue;
int enqueued;
int ready; /**< Number of blocks in smps[] which are allocated and ready to be used by node_read(). */
-
+
struct path_source *ps = p->source;
-
+
int cnt = ps->node->vectorize;
struct sample *smps[cnt];
@@ -83,7 +83,7 @@ static void path_read(struct path *p)
int refd = 0;
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = list_at(&p->destinations, i);
-
+
enqueued = queue_push_many(&pd->queue, (void **) smps, enqueue);
if (enqueue != enqueued)
warn("Queue overrun for path %s", path_name(p));
@@ -102,7 +102,7 @@ static void path_write(struct path *p)
{
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = list_at(&p->destinations, i);
-
+
int cnt = pd->node->vectorize;
int sent;
int tosend;
@@ -116,9 +116,9 @@ static void path_write(struct path *p)
available = queue_pull_many(&pd->queue, (void **) smps, cnt);
if (available == 0)
break;
- else if (available < cnt)
+ else if (available < cnt)
debug(LOG_PATH | 5, "Queue underrun for path %s: available=%u expected=%u", path_name(p), available, cnt);
-
+
debug(LOG_PATH | 15, "Dequeued %u samples from queue of node %s which is part of path %s", available, node_name(pd->node), path_name(p));
tosend = hook_write_list(&p->hooks, smps, available);
@@ -134,7 +134,7 @@ static void path_write(struct path *p)
debug(LOG_PATH | 15, "Sent %u messages to node %s", sent, node_name(pd->node));
released = sample_put_many(smps, sent);
-
+
debug(LOG_PATH | 15, "Released %d samples back to memory pool", released);
}
}
@@ -156,14 +156,14 @@ static void * path_run(void *arg)
static int path_source_destroy(struct path_source *ps)
{
pool_destroy(&ps->pool);
-
+
return 0;
}
static int path_destination_destroy(struct path_destination *pd)
{
queue_destroy(&pd->queue);
-
+
return 0;
}
@@ -173,18 +173,18 @@ int path_init(struct path *p, struct super_node *sn)
list_init(&p->hooks);
list_init(&p->destinations);
-
+
/* Default values */
p->reverse = 0;
p->enabled = 1;
p->samplelen = DEFAULT_SAMPLELEN;
p->queuelen = DEFAULT_QUEUELEN;
-
+
p->super_node = sn;
-
+
p->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -196,7 +196,7 @@ int path_parse(struct path *p, config_setting_t *cfg, struct list *nodes)
struct node *source;
struct list destinations = { .state = STATE_DESTROYED };
-
+
list_init(&destinations);
/* Input node */
@@ -253,7 +253,7 @@ int path_parse(struct path *p, config_setting_t *cfg, struct list *nodes)
.node = n,
.queuelen = p->queuelen
};
-
+
list_push(&p->destinations, memdup(&pd, sizeof(pd)));
}
@@ -265,19 +265,19 @@ int path_parse(struct path *p, config_setting_t *cfg, struct list *nodes)
int path_check(struct path *p)
{
assert(p->state != STATE_DESTROYED);
-
+
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = list_at(&p->destinations, i);
-
+
if (!pd->node->_vt->write)
error("Destiation node '%s' is not supported as a sink for path '%s'", node_name(pd->node), path_name(p));
}
if (!p->source->node->_vt->read)
error("Source node '%s' is not supported as source for path '%s'", node_name(p->source->node), path_name(p));
-
+
p->state = STATE_CHECKED;
-
+
return 0;
}
@@ -290,7 +290,7 @@ int path_init2(struct path *p)
/* Add internal hooks if they are not already in the list*/
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *q = list_at(&plugins, i);
-
+
if (q->type == PLUGIN_TYPE_HOOK) {
struct hook h = { .state = STATE_DESTROYED };
struct hook_type *vt = &q->hook;
@@ -304,7 +304,7 @@ int path_init2(struct path *p)
}
}
}
-
+
/* We sort the hooks according to their priority before starting the path */
list_sort(&p->hooks, hook_cmp_priority);
@@ -315,23 +315,23 @@ int path_init2(struct path *p)
ret = queue_init(&pd->queue, pd->queuelen, &memtype_hugepage);
if (ret)
error("Failed to initialize queue for path");
-
+
if (pd->queuelen > max_queuelen)
max_queuelen = pd->queuelen;
}
-
+
/* Initialize source */
ret = pool_init(&p->source->pool, max_queuelen, SAMPLE_LEN(p->source->samplelen), &memtype_hugepage);
if (ret)
error("Failed to allocate memory pool for path");
-
+
return 0;
}
int path_start(struct path *p)
{
int ret;
-
+
assert(p->state == STATE_CHECKED);
info("Starting path %s: #hooks=%zu, #destinations=%zu", path_name(p), list_length(&p->hooks), list_length(&p->destinations));
@@ -358,7 +358,7 @@ int path_start(struct path *p)
int path_stop(struct path *p)
{
int ret;
-
+
if (p->state != STATE_STARTED)
return 0;
@@ -387,7 +387,7 @@ int path_destroy(struct path *p)
list_destroy(&p->hooks, (dtor_cb_t) hook_destroy, true);
list_destroy(&p->destinations, (dtor_cb_t) path_destination_destroy, true);
-
+
path_source_destroy(p->source);
if (p->_name)
@@ -395,9 +395,9 @@ int path_destroy(struct path *p)
if (p->source)
free(p->source);
-
+
p->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -406,20 +406,20 @@ const char * path_name(struct path *p)
if (!p->_name) {
if (list_length(&p->destinations) == 1) {
struct path_destination *pd = (struct path_destination *) list_first(&p->destinations);
-
+
strcatf(&p->_name, "%s " MAG("=>") " %s",
node_name_short(p->source->node),
node_name_short(pd->node));
}
else {
strcatf(&p->_name, "%s " MAG("=>") " [", node_name_short(p->source->node));
-
+
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = list_at(&p->destinations, i);
strcatf(&p->_name, " %s", node_name_short(pd->node));
}
-
+
strcatf(&p->_name, " ]");
}
}
@@ -444,37 +444,37 @@ int path_reverse(struct path *p, struct path *r)
if (list_length(&p->destinations) > 1)
return -1;
-
+
struct path_destination *first_pd = list_first(&p->destinations);
/* General */
r->enabled = p->enabled;
r->cfg = p->cfg;
-
+
struct path_destination *pd = alloc(sizeof(struct path_destination));
-
+
pd->node = p->source->node;
pd->queuelen = first_pd->queuelen;
list_push(&r->destinations, pd);
-
+
struct path_source *ps = alloc(sizeof(struct path_source));
ps->node = first_pd->node;
ps->samplelen = p->source->samplelen;
-
+
r->source = ps;
for (size_t i = 0; i < list_length(&p->hooks); i++) {
struct hook *h = list_at(&p->hooks, i);
struct hook hc = { .state = STATE_DESTROYED };
-
+
ret = hook_init(&hc, h->_vt, p);
if (ret)
return ret;
-
+
list_push(&r->hooks, memdup(&hc, sizeof(hc)));
}
-
+
return 0;
}
diff --git a/lib/plugin.c b/lib/plugin.c
index 8a2d60436..85183a4fb 100644
--- a/lib/plugin.c
+++ b/lib/plugin.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,7 +37,7 @@ int plugin_init(struct plugin *p)
assert(p->state == STATE_DESTROYED);
p->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -57,24 +57,24 @@ int plugin_load(struct plugin *p)
p->handle = dlopen(p->path, RTLD_NOW);
if (!p->path)
return -1;
-
+
p->state = STATE_LOADED;
-
+
return 0;
}
int plugin_unload(struct plugin *p)
{
int ret;
-
+
assert(p->state == STATE_LOADED);
-
+
ret = dlclose(p->handle);
if (ret)
return -1;
-
+
p->state = STATE_UNLOADED;
-
+
return 0;
}
@@ -84,7 +84,7 @@ int plugin_destroy(struct plugin *p)
if (p->path)
free(p->path);
-
+
return 0;
}
@@ -96,7 +96,7 @@ struct plugin * plugin_lookup(enum plugin_type type, const char *name)
if (p->type == type && strcmp(p->name, name) == 0)
return p;
}
-
+
return NULL;
}
diff --git a/lib/pool.c b/lib/pool.c
index b456fd317..df710a1ed 100644
--- a/lib/pool.c
+++ b/lib/pool.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -29,7 +29,7 @@
int pool_init(struct pool *p, size_t cnt, size_t blocksz, struct memtype *m)
{
int ret;
-
+
assert(p->state == STATE_DESTROYED);
/* Make sure that we use a block size that is aligned to the size of a cache line */
@@ -48,10 +48,10 @@ int pool_init(struct pool *p, size_t cnt, size_t blocksz, struct memtype *m)
ret = queue_init(&p->queue, LOG2_CEIL(cnt), m);
if (ret)
return ret;
-
+
for (int i = 0; i < cnt; i++)
queue_push(&p->queue, (char *) buffer + i * p->blocksz);
-
+
p->state = STATE_INITIALIZED;
return 0;
@@ -64,7 +64,7 @@ int pool_destroy(struct pool *p)
if (p->state == STATE_DESTROYED)
return 0;
- queue_destroy(&p->queue);
+ queue_destroy(&p->queue);
void *buffer = (char*) p + p->buffer_off;
ret = memory_free(p->mem, buffer, p->len);
diff --git a/lib/queue.c b/lib/queue.c
index 3b1f04fe8..3d61d0dd1 100644
--- a/lib/queue.c
+++ b/lib/queue.c
@@ -6,19 +6,19 @@
* @author Steffen Vogel
* @copyright 2017 Steffen Vogel
* @license BSD 2-Clause License
- *
+ *
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modiffication, are permitted provided that the following conditions are met:
- *
+ *
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -46,7 +46,7 @@ int queue_init(struct queue *q, size_t size, struct memtype *mem)
size = LOG2_CEIL(size);
warn("A queue size was changed from %lu to %lu", old_size, size);
}
-
+
q->mem = mem;
q->buffer_mask = size - 1;
struct queue_cell* buffer = memory_alloc(q->mem, sizeof(struct queue_cell) * size);
@@ -54,15 +54,15 @@ int queue_init(struct queue *q, size_t size, struct memtype *mem)
return -2;
q->buffer_off = (char *) buffer - (char *) q;
-
+
for (size_t i = 0; i != size; i += 1)
atomic_store_explicit(&buffer[i].sequence, i, memory_order_relaxed);
atomic_store_explicit(&q->tail, 0, memory_order_relaxed);
atomic_store_explicit(&q->head, 0, memory_order_relaxed);
-
+
q->state = STATE_INITIALIZED;
-
+
return 0;
}
@@ -78,7 +78,7 @@ int queue_destroy(struct queue *q)
if (ret == 0)
q->state = STATE_DESTROYED;
-
+
return ret;
}
@@ -86,7 +86,7 @@ int queue_destroy(struct queue *q)
*
* Note: This is only an estimation and not accurate as long other
* threads are performing operations.
- */
+ */
size_t queue_available(struct queue *q)
{
return atomic_load_explicit(&q->tail, memory_order_relaxed) -
@@ -127,7 +127,7 @@ int queue_pull(struct queue *q, void **ptr)
struct queue_cell *cell, *buffer;
size_t pos, seq;
intptr_t diff;
-
+
buffer = (struct queue_cell *) ((char *) q + q->buffer_off);
pos = atomic_load_explicit(&q->head, memory_order_relaxed);
for (;;) {
@@ -161,7 +161,7 @@ int queue_push_many(struct queue *q, void *ptr[], size_t cnt)
if (!ret)
break;
}
-
+
return i;
}
@@ -175,6 +175,6 @@ int queue_pull_many(struct queue *q, void *ptr[], size_t cnt)
if (!ret)
break;
}
-
+
return i;
}
diff --git a/lib/queue_signalled.c b/lib/queue_signalled.c
index 1c5dfd9cb..38f372e49 100644
--- a/lib/queue_signalled.c
+++ b/lib/queue_signalled.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,12 +37,12 @@ int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memtype
pthread_mutexattr_init(&mtattr);
pthread_condattr_init(&cvattr);
- pthread_mutexattr_setpshared(&mtattr, PTHREAD_PROCESS_SHARED);
+ pthread_mutexattr_setpshared(&mtattr, PTHREAD_PROCESS_SHARED);
pthread_condattr_setpshared(&cvattr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(&qs->mutex, &mtattr);
pthread_cond_init(&qs->ready, &cvattr);
-
+
pthread_mutexattr_destroy(&mtattr);
pthread_condattr_destroy(&cvattr);
@@ -66,11 +66,11 @@ int queue_signalled_destroy(struct queue_signalled *qs)
int queue_signalled_push(struct queue_signalled *qs, void *ptr)
{
int ret;
-
+
ret = queue_push(&qs->queue, ptr);
if (ret < 0)
return ret;
-
+
pthread_mutex_lock(&qs->mutex);
pthread_cond_broadcast(&qs->ready);
pthread_mutex_unlock(&qs->mutex);
@@ -81,11 +81,11 @@ int queue_signalled_push(struct queue_signalled *qs, void *ptr)
int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cnt)
{
int ret;
-
+
ret = queue_push_many(&qs->queue, ptr, cnt);
if (ret < 0)
return ret;
-
+
pthread_mutex_lock(&qs->mutex);
pthread_cond_broadcast(&qs->ready);
pthread_mutex_unlock(&qs->mutex);
@@ -101,7 +101,7 @@ int queue_signalled_pull(struct queue_signalled *qs, void **ptr)
pthread_cond_wait(&qs->ready, &qs->mutex);
pthread_mutex_unlock(&qs->mutex);
pthread_cleanup_pop(0);
-
+
return queue_pull(&qs->queue, ptr);
}
@@ -113,6 +113,6 @@ int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cn
pthread_cond_wait(&qs->ready, &qs->mutex);
pthread_mutex_unlock(&qs->mutex);
pthread_cleanup_pop(0);
-
+
return queue_pull_many(&qs->queue, ptr, cnt);
}
diff --git a/lib/sample.c b/lib/sample.c
index ff3183531..e9c16f33d 100644
--- a/lib/sample.c
+++ b/lib/sample.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -55,12 +55,12 @@ void sample_free(struct sample *smps[], int cnt)
int sample_put_many(struct sample *smps[], int cnt)
{
int released = 0;
-
+
for (int i = 0; i < cnt; i++) {
if (sample_put(smps[i]) == 0)
released++;
}
-
+
return released;
}
@@ -68,7 +68,7 @@ int sample_get_many(struct sample *smps[], int cnt)
{
for (int i = 0; i < cnt; i++)
sample_get(smps[i]);
-
+
return cnt;
}
@@ -80,13 +80,13 @@ int sample_get(struct sample *s)
int sample_put(struct sample *s)
{
int prev = atomic_fetch_sub(&s->refcnt, 1);
-
+
/* Did we had the last reference? */
if (prev == 1) {
struct pool *p = (struct pool *) ((char *) s + s->pool_off);
pool_put(p, s);
}
-
+
return prev - 1;
}
@@ -97,13 +97,13 @@ int sample_copy(struct sample *dst, struct sample *src)
dst->sequence = src->sequence;
dst->format = src->format;
dst->source = src->source;
-
+
dst->ts.origin = src->ts.origin;
dst->ts.received = src->ts.received;
dst->ts.sent = src->ts.sent;
memcpy(&dst->data, &src->data, SAMPLE_DATA_LEN(dst->length));
-
+
return 0;
}
@@ -111,7 +111,7 @@ int sample_copy_many(struct sample *dsts[], struct sample *srcs[], int cnt)
{
for (int i = 0; i < cnt; i++)
sample_copy(dsts[i], srcs[i]);
-
+
return cnt;
}
@@ -119,12 +119,12 @@ int sample_set_data_format(struct sample *s, int idx, enum sample_data_format fm
{
if (idx >= sizeof(s->format) * 8)
return 0; /* we currently can only control the format of the first 64 values. */
-
+
switch (fmt) {
case SAMPLE_DATA_FORMAT_FLOAT: s->format &= ~(1 << idx); break;
case SAMPLE_DATA_FORMAT_INT: s->format |= (fmt << idx); break;
}
-
+
return 0;
}
@@ -132,6 +132,6 @@ int sample_get_data_format(struct sample *s, int idx)
{
if (idx >= sizeof(s->format) * 8)
return -1; /* we currently can only control the format of the first 64 values. */
-
+
return (s->format >> idx) & 0x1;
}
diff --git a/lib/sample_io.c b/lib/sample_io.c
index 62ed506f8..79ef6d536 100644
--- a/lib/sample_io.c
+++ b/lib/sample_io.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -50,13 +50,13 @@ int sample_io_fscan(FILE *f, struct sample *s, enum sample_io_format fmt, int *f
int sample_io_villas_print(char *buf, size_t len, struct sample *s, int flags)
{
size_t off = snprintf(buf, len, "%llu", (unsigned long long) s->ts.origin.tv_sec);
-
+
if (flags & SAMPLE_IO_NANOSECONDS)
off += snprintf(buf + off, len - off, ".%09llu", (unsigned long long) s->ts.origin.tv_nsec);
-
+
if (flags & SAMPLE_IO_OFFSET)
off += snprintf(buf + off, len - off, "%+e", time_delta(&s->ts.origin, &s->ts.received));
-
+
if (flags & SAMPLE_IO_SEQUENCE)
off += snprintf(buf + off, len - off, "(%u)", s->sequence);
@@ -86,7 +86,7 @@ int sample_io_villas_scan(const char *line, struct sample *s, int *fl)
int flags = 0;
double offset = 0;
- /* Format: Seconds.NanoSeconds+Offset(SequenceNumber) Value1 Value2 ...
+ /* Format: Seconds.NanoSeconds+Offset(SequenceNumber) Value1 Value2 ...
* RegEx: (\d+(?:\.\d+)?)([-+]\d+(?:\.\d+)?(?:e[+-]?\d+)?)?(?:\((\d+)\))?
*
* Please note that only the seconds and at least one value are mandatory
@@ -120,17 +120,17 @@ int sample_io_villas_scan(const char *line, struct sample *s, int *fl)
else
return -4;
}
-
+
/* Optional: sequence */
if (*end == '(') {
ptr = end + 1;
-
+
s->sequence = strtoul(ptr, &end, 10);
if (ptr != end)
flags |= SAMPLE_IO_SEQUENCE;
else
return -5;
-
+
if (*end == ')')
end++;
}
@@ -151,10 +151,10 @@ int sample_io_villas_scan(const char *line, struct sample *s, int *fl)
if (end == ptr) /* There are no valid FP values anymore */
break;
}
-
+
if (s->length > 0)
flags |= SAMPLE_IO_VALUES;
-
+
if (fl)
*fl = flags;
if (flags & SAMPLE_IO_OFFSET) {
@@ -171,20 +171,20 @@ int sample_io_villas_fprint(FILE *f, struct sample *s, int flags)
{
char line[4096];
int ret;
-
+
ret = sample_io_villas_print(line, sizeof(line), s, flags);
if (ret)
return ret;
fputs(line, f);
-
+
return 0;
}
int sample_io_villas_fscan(FILE *f, struct sample *s, int *fl)
{
char *ptr, line[4096];
-
+
skip: if (fgets(line, sizeof(line), f) == NULL)
return -1; /* An error occured */
@@ -192,7 +192,7 @@ skip: if (fgets(line, sizeof(line), f) == NULL)
for (ptr = line; isspace(*ptr); ptr++);
if (*ptr == '\0' || *ptr == '#')
goto skip;
-
+
return sample_io_villas_scan(line, s, fl);
}
diff --git a/lib/shmem.c b/lib/shmem.c
index 005527fc8..c90617595 100644
--- a/lib/shmem.c
+++ b/lib/shmem.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -54,7 +54,7 @@ struct shmem_shared * shmem_shared_open(const char *name, void **base_ptr)
void *base;
char *cptr;
int fd, ret;
-
+
fd = shm_open(name, O_RDWR, 0);
if (fd < 0)
return NULL;
@@ -62,7 +62,7 @@ struct shmem_shared * shmem_shared_open(const char *name, void **base_ptr)
/* Only map the first part (shmem_shared) first, read the correct length,
* the map it with this length. */
len = sizeof(struct memtype) + sizeof(struct memblock) + sizeof(struct shmem_shared);
-
+
base = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (base == MAP_FAILED)
return NULL;
@@ -109,7 +109,7 @@ int shmem_shared_close(struct shmem_shared *shm, void *base)
int shmem_shared_read(struct shmem_shared *shm, struct sample *smps[], unsigned cnt)
{
int ret;
-
+
ret = shm->polling ? queue_pull_many(&shm->out.q, (void **) smps, cnt)
: queue_signalled_pull_many(&shm->out.qs, (void **) smps, cnt);
diff --git a/lib/stats.c b/lib/stats.c
index 5bdbdba20..483a6d3ed 100644
--- a/lib/stats.c
+++ b/lib/stats.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -53,7 +53,7 @@ int stats_init(struct stats *s)
struct stats_desc *desc = &stats_table[i];
hist_init(&s->histograms[i], desc->hist.min, desc->hist.max, desc->hist.resolution);
}
-
+
s->delta = alloc(sizeof(struct stats_delta));
return 0;
@@ -64,14 +64,14 @@ void stats_destroy(struct stats *s)
for (int i = 0; i < STATS_COUNT; i++) {
hist_destroy(&s->histograms[i]);
}
-
+
free(s->delta);
}
void stats_update(struct stats_delta *d, enum stats_id id, double val)
{
assert(id >= 0 && id < STATS_COUNT);
-
+
d->values[id] = val;
d->update |= 1 << id;
}
@@ -84,7 +84,7 @@ int stats_commit(struct stats *s, struct stats_delta *d)
d->update &= ~(1 << i);
}
}
-
+
return 0;
}
@@ -92,19 +92,19 @@ void stats_collect(struct stats_delta *s, struct sample *smps[], size_t cnt)
{
int dist;
struct sample *previous = s->last;
-
+
for (int i = 0; i < cnt; i++) {
if (previous) {
stats_update(s, STATS_GAP_RECEIVED, time_delta(&previous->ts.received, &smps[i]->ts.received));
stats_update(s, STATS_GAP_SAMPLE, time_delta(&previous->ts.origin, &smps[i]->ts.origin));
stats_update(s, STATS_OWD, -time_delta(&smps[i]->ts.origin, &smps[i]->ts.received));
stats_update(s, STATS_GAP_SEQUENCE, smps[i]->sequence - (int32_t) previous->sequence);
-
+
dist = smps[i]->sequence - (int32_t) previous->sequence;
if (dist > 0)
stats_update(s, STATS_REORDERED, dist);
}
-
+
previous = smps[i];
}
@@ -124,12 +124,12 @@ json_t * stats_json(struct stats *s)
for (int i = 0; i < STATS_COUNT; i++) {
struct stats_desc *desc = &stats_table[i];
-
+
json_t *stats = hist_json(&s->histograms[i]);
-
+
json_object_set(obj, desc->name, stats);
}
-
+
return obj;
}
@@ -155,7 +155,7 @@ void stats_reset(struct stats *s)
void stats_print_header(enum stats_format fmt)
{
#define UNIT(u) "(" YEL(u) ")"
-
+
switch (fmt) {
case STATS_FORMAT_HUMAN:
stats("%-40s|%19s|%19s|%19s|%19s|", "Source " MAG("=>") " Destination",
@@ -166,7 +166,7 @@ void stats_print_header(enum stats_format fmt)
);
line();
break;
-
+
default: { }
}
}
@@ -182,13 +182,13 @@ void stats_print_periodic(struct stats *s, FILE *f, enum stats_format fmt, int v
s->histograms[STATS_SKIPPED].total
);
break;
-
+
case STATS_FORMAT_JSON: {
json_t *json_stats = stats_json_periodic(s, p);
json_dumpf(json_stats, f, 0);
break;
}
-
+
default: { }
}
}
@@ -199,19 +199,19 @@ void stats_print(struct stats *s, FILE *f, enum stats_format fmt, int verbose)
case STATS_FORMAT_HUMAN:
for (int i = 0; i < STATS_COUNT; i++) {
struct stats_desc *desc = &stats_table[i];
-
+
stats("%s: %s", desc->name, desc->desc);
hist_print(&s->histograms[i], verbose);
}
break;
-
+
case STATS_FORMAT_JSON: {
json_t *json_stats = stats_json(s);
json_dumpf(json_stats, f, 0);
fflush(f);
break;
}
-
+
default: { }
}
}
@@ -220,9 +220,9 @@ void stats_send(struct stats *s, struct node *n)
{
char buf[SAMPLE_LEN(STATS_COUNT * 5)];
struct sample *smp = (struct sample *) buf;
-
+
int i = 0;
-
+
for (int j = 0; j < STATS_COUNT; j++) {
smp->data[i++].f = s->histograms[j].last;
smp->data[i++].f = s->histograms[j].highest;
@@ -231,7 +231,7 @@ void stats_send(struct stats *s, struct node *n)
smp->data[i++].f = hist_var(&s->histograms[j]);
}
smp->length = i;
-
+
node_write(n, &smp, 1); /* Send single message with statistics to destination node */
}
@@ -239,10 +239,10 @@ enum stats_id stats_lookup_id(const char *name)
{
for (int i = 0; i < STATS_COUNT; i++) {
struct stats_desc *desc = &stats_table[i];
-
+
if (!strcmp(desc->name, name))
return i;
}
-
+
return -1;
}
\ No newline at end of file
diff --git a/lib/super_node.c b/lib/super_node.c
index 86a22c88f..709b1f934 100644
--- a/lib/super_node.c
+++ b/lib/super_node.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -74,13 +74,13 @@ int super_node_init(struct super_node *sn)
list_init(&sn->nodes);
list_init(&sn->paths);
list_init(&sn->plugins);
-
+
/* Default values */
sn->affinity = 0;
sn->priority = 0;
sn->stats = 0;
sn->hugepages = DEFAULT_NR_HUGEPAGES;
-
+
sn->state = STATE_INITIALIZED;
return 0;
@@ -110,19 +110,19 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
char *include_dir = dirname(uri_cpy);
config_set_include_dir(&sn->cfg, include_dir);
-
+
free(uri_cpy);
af = NULL;
f = fopen(uri, "r");
-
+
info("Reading configuration from local file: %s", uri);
}
/* Use advio (libcurl) to fetch the config from a remote */
else {
af = afopen(uri, "r");
f = af ? af->file : NULL;
-
+
info("Reading configuration from URI: %s", uri);
}
@@ -138,10 +138,10 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
if (ret != CONFIG_TRUE) {
/* This does not seem to be a valid libconfig configuration.
* Lets try to parse it as JSON instead. */
-
+
json_error_t err;
json_t *json;
-
+
json = json_loadf(f, 0, &err);
if (json) {
ret = json_to_config(json, cfg_root);
@@ -173,17 +173,17 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
else { INDENT
warn("No configuration file specified. Starting unconfigured. Use the API to configure this instance.");
}
-
+
return 0;
}
int super_node_parse_cli(struct super_node *sn, int argc, char *argv[])
{
char *uri = (argc == 2) ? argv[1] : NULL;
-
+
sn->cli.argc = argc;
sn->cli.argv = argv;
-
+
return super_node_parse_uri(sn, uri);
}
@@ -193,7 +193,7 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
assert(sn->state != STATE_STARTED);
assert(sn->state != STATE_DESTROYED);
-
+
config_setting_t *cfg_nodes, *cfg_paths, *cfg_plugins, *cfg_logging, *cfg_web;
super_node_parse_global(sn, cfg);
@@ -215,17 +215,17 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
for (int i = 0; i < config_setting_length(cfg_plugins); i++) {
struct config_setting_t *cfg_plugin = config_setting_get_elem(cfg_plugins, i);
-
+
struct plugin plugin = { .state = STATE_DESTROYED };
-
+
ret = plugin_init(&plugin);
if (ret)
cerror(cfg_plugin, "Failed to initialize plugin");
-
+
ret = plugin_parse(&plugin, cfg_plugin);
if (ret)
cerror(cfg_plugin, "Failed to parse plugin");
-
+
list_push(&sn->plugins, memdup(&plugin, sizeof(plugin)));
}
}
@@ -251,9 +251,9 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
cerror(cfg_node, "Invalid node type: %s", type);
struct node *n = alloc(sizeof(struct node));
-
+
n->state = STATE_DESTROYED;
-
+
ret = node_init(n, &p->node);
if (ret)
cerror(cfg_node, "Failed to initialize node");
@@ -261,7 +261,7 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
ret = node_parse(n, cfg_node);
if (ret)
cerror(cfg_node, "Failed to parse node");
-
+
list_push(&sn->nodes, n);
}
}
@@ -276,7 +276,7 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
config_setting_t *cfg_path = config_setting_get_elem(cfg_paths, i);
struct path p = { .state = STATE_DESTROYED };
-
+
ret = path_init(&p, sn);
if (ret)
cerror(cfg_path, "Failed to init path");
@@ -284,16 +284,16 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
ret = path_parse(&p, cfg_path, &sn->nodes);
if (ret)
cerror(cfg_path, "Failed to parse path");
-
+
list_push(&sn->paths, memdup(&p, sizeof(p)));
if (p.reverse) {
struct path r = { .state = STATE_DESTROYED };
-
+
ret = path_init(&r, sn);
if (ret)
cerror(cfg_path, "Failed to init path");
-
+
ret = path_reverse(&p, &r);
if (ret)
cerror(cfg_path, "Failed to reverse path %s", path_name(&p));
@@ -302,7 +302,7 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
}
}
}
-
+
sn->state = STATE_PARSED;
return 0;
@@ -311,7 +311,7 @@ int super_node_parse(struct super_node *sn, config_setting_t *cfg)
int super_node_check(struct super_node *sn)
{
int ret;
-
+
assert(sn->state != STATE_DESTROYED);
for (size_t i = 0; i < list_length(&sn->nodes); i++) {
@@ -321,7 +321,7 @@ int super_node_check(struct super_node *sn)
if (ret)
error("Invalid configuration for node %s", node_name(n));
}
-
+
for (size_t i = 0; i < list_length(&sn->paths); i++) {
struct path *p = list_at(&sn->paths, i);
@@ -329,7 +329,7 @@ int super_node_check(struct super_node *sn)
if (ret)
error("Invalid configuration for path %s", path_name(p));
}
-
+
sn->state = STATE_CHECKED;
return 0;
@@ -345,14 +345,14 @@ int super_node_start(struct super_node *sn)
log_start(&sn->log);
api_start(&sn->api);
web_start(&sn->web);
-
+
info("Start node types");
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
struct node *n = list_at(&sn->nodes, i);
-
+
node_type_start(n->_vt, sn);
}
-
+
info("Starting nodes");
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
struct node *n = list_at(&sn->nodes, i);
@@ -367,7 +367,7 @@ int super_node_start(struct super_node *sn)
info("Starting paths");
for (size_t i = 0; i < list_length(&sn->paths); i++) { INDENT
struct path *p = list_at(&sn->paths, i);
-
+
if (p->enabled) {
path_init2(p);
path_start(p);
@@ -375,9 +375,9 @@ int super_node_start(struct super_node *sn)
else
warn("Path %s is disabled. Skipping...", path_name(p));
}
-
+
sn->state = STATE_STARTED;
-
+
return 0;
}
@@ -417,9 +417,9 @@ int super_node_stop(struct super_node *sn)
web_stop(&sn->web);
api_stop(&sn->api);
log_stop(&sn->log);
-
+
sn->state = STATE_STOPPED;
-
+
return 0;
}
@@ -438,6 +438,6 @@ int super_node_destroy(struct super_node *sn)
config_destroy(&sn->cfg);
sn->state = STATE_DESTROYED;
-
+
return 0;
}
diff --git a/lib/timing.c b/lib/timing.c
index f6745c41e..9f34bffb2 100644
--- a/lib/timing.c
+++ b/lib/timing.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -28,9 +28,9 @@
int timerfd_create_rate(double rate)
{
int fd, ret;
-
+
struct timespec ts = time_from_double(1 / rate);
-
+
struct itimerspec its = {
.it_interval = ts,
.it_value = ts
@@ -43,7 +43,7 @@ int timerfd_create_rate(double rate)
ret = timerfd_settime(fd, 0, &its, NULL);
if (ret)
return ret;
-
+
return fd;
}
@@ -65,7 +65,7 @@ uint64_t timerfd_wait_until(int fd, struct timespec *until)
ret = timerfd_settime(fd, TFD_TIMER_ABSTIME, &its, NULL);
if (ret)
return 0;
-
+
return timerfd_wait(fd);
}
@@ -74,7 +74,7 @@ struct timespec time_now()
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
-
+
return ts;
}
diff --git a/lib/utils.c b/lib/utils.c
index 7e4764cb9..27232d0a8 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -112,7 +112,7 @@ char * vstrcatf(char **dest, const char *fmt, va_list ap)
*dest = (char *)(realloc(*dest, n + i + 1));
if (*dest != NULL)
strncpy(*dest+n, tmp, i + 1);
-
+
free(tmp);
return *dest;
@@ -192,7 +192,7 @@ int cpulist_parse(const char *str, cpu_set_t *set, int fail)
if (r == 2)
return 1;
-
+
return 0;
}
@@ -251,9 +251,9 @@ void * alloc(size_t bytes)
void * memdup(const void *src, size_t bytes)
{
void *dst = alloc(bytes);
-
+
memcpy(dst, src, bytes);
-
+
return dst;
}
@@ -275,9 +275,9 @@ ssize_t read_random(char *buf, size_t len)
total += bytes;
}
-
+
close(fd);
-
+
return bytes;
}
@@ -287,10 +287,10 @@ void rdtsc_sleep(uint64_t nanosecs, uint64_t start)
/** @todo Replace the hard coded CPU clock frequency */
cycles = (double) nanosecs / (1e9 / 3392389000);
-
+
if (start == 0)
start = rdtsc();
-
+
do {
__asm__("nop");
} while (rdtsc() - start < cycles);
@@ -300,7 +300,7 @@ void rdtsc_sleep(uint64_t nanosecs, uint64_t start)
void signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx))
{
info("Initialize signals");
-
+
struct sigaction sa_quit = {
.sa_flags = SA_SIGINFO,
.sa_sigaction = cb
@@ -321,12 +321,12 @@ void signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx))
pid_t spawn(const char* name, char *const argv[])
{
pid_t pid;
-
+
pid = fork();
switch (pid) {
case -1: return -1;
case 0: return execvp(name, (char * const*) argv);
}
-
+
return pid;
}
diff --git a/lib/web.c b/lib/web.c
index c4d8eda8e..11f87c5a3 100644
--- a/lib/web.c
+++ b/lib/web.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -126,11 +126,11 @@ static void logger(int level, const char *msg) {
int len = strlen(msg);
if (strchr(msg, '\n'))
len -= 1;
-
+
/* Decrease severity for some errors. */
if (strstr(msg, "Unable to open") == msg)
level = LLL_WARN;
-
+
switch (level) {
case LLL_ERR: warn("LWS: %.*s", len, msg); break;
case LLL_WARN: warn("LWS: %.*s", len, msg); break;
@@ -142,12 +142,12 @@ static void logger(int level, const char *msg) {
static void * worker(void *ctx)
{
struct web *w = ctx;
-
+
assert(w->state == STATE_STARTED);
for (;;)
lws_service(w->context, 100);
-
+
return NULL;
}
@@ -156,11 +156,11 @@ int web_init(struct web *w, struct api *a)
lws_set_log_level((1 << LLL_COUNT) - 1, logger);
w->api = a;
-
+
/* Default values */
w->port = 80;
w->htdocs = WEB_PATH;
-
+
w->state = STATE_INITIALIZED;
return 0;
@@ -178,7 +178,7 @@ int web_parse(struct web *w, config_setting_t *cfg)
config_setting_lookup_int(cfg, "port", &w->port);
config_setting_lookup_string(cfg, "htdocs", &w->htdocs);
config_setting_lookup_bool(cfg, "enabled", &enabled);
-
+
if (!enabled)
w->port = CONTEXT_PORT_NO_LISTEN;
@@ -198,7 +198,7 @@ int web_start(struct web *w)
.uid = -1,
.user = (void *) w
};
-
+
struct lws_context_creation_info vhost_info = {
.protocols = protocols,
.mounts = mounts,
@@ -217,12 +217,12 @@ int web_start(struct web *w)
w->context = lws_create_context(&ctx_info);
if (w->context == NULL)
error("WebSocket: failed to initialize server");
-
+
w->vhost = lws_create_vhost(w->context, &vhost_info);
if (w->vhost == NULL)
error("WebSocket: failed to initialize server");
}
-
+
ret = pthread_create(&w->thread, NULL, worker, w);
if (ret)
error("Failed to start Web worker");
@@ -238,12 +238,12 @@ int web_stop(struct web *w)
if (w->state == STATE_STARTED)
lws_cancel_service(w->context);
-
+
/** @todo Wait for all connections to be closed */
-
+
pthread_cancel(w->thread);
pthread_join(w->thread, NULL);
-
+
w->state = STATE_STOPPED;
return 0;
@@ -253,7 +253,7 @@ int web_destroy(struct web *w)
{
if (w->state == STATE_DESTROYED)
return 0;
-
+
if (w->context)
lws_context_destroy(w->context);
diff --git a/lib/web/buffer.c b/lib/web/buffer.c
index fcd2d3e1f..c45912956 100644
--- a/lib/web/buffer.c
+++ b/lib/web/buffer.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -31,13 +31,13 @@
int web_buffer_init(struct web_buffer *b, enum lws_write_protocol prot)
{
assert(b->state == STATE_DESTROYED);
-
+
b->protocol = prot;
b->size = 0;
b->len = 0;
b->buffer = NULL;
b->prefix = b->protocol == LWS_WRITE_TEXT || b->protocol == LWS_WRITE_BINARY ? LWS_PRE : 0;
-
+
b->state = STATE_INITIALIZED;
return 0;
@@ -47,12 +47,12 @@ int web_buffer_destroy(struct web_buffer *b)
{
if (b->state == STATE_DESTROYED)
return 0;
-
+
if (b->buffer)
free(b->buffer);
-
+
b->state = STATE_DESTROYED;
-
+
return 0;
}
@@ -60,12 +60,12 @@ int web_buffer_write(struct web_buffer *b, struct lws *w)
{
int ret, len, sent = 0;
unsigned char *chunk;
-
+
assert(b->state == STATE_INITIALIZED);
-
+
if (b->len <= 0)
return 0;
-
+
do {
chunk = (unsigned char *) b->buffer + b->prefix + sent;
len = strlen(b->buffer + b->prefix);
@@ -78,7 +78,7 @@ int web_buffer_write(struct web_buffer *b, struct lws *w)
} while (sent < b->len);
web_buffer_read(b, NULL, sent); /* drop sent bytes from the buffer*/
-
+
return sent;
}
@@ -91,10 +91,10 @@ int web_buffer_read(struct web_buffer *b, char *out, size_t len)
if (out)
memcpy(out, b->buffer + b->prefix, len);
-
+
memmove(b->buffer + b->prefix, b->buffer + b->prefix + len, b->len - len);
b->len -= len;
-
+
return 0;
}
@@ -110,7 +110,7 @@ int web_buffer_read_json(struct web_buffer *b, json_t **req)
*req = json_loadb(b->buffer + b->prefix, b->len, JSON_DISABLE_EOF_CHECK, &e);
if (!*req)
return -2;
-
+
web_buffer_read(b, NULL, e.position);
return 1;
@@ -119,22 +119,22 @@ int web_buffer_read_json(struct web_buffer *b, json_t **req)
int web_buffer_append(struct web_buffer *b, const char *in, size_t len)
{
assert(b->state == STATE_INITIALIZED);
-
+
/* We append a \0 to split messages */
len++;
-
+
if (b->size < b->len + len) {
b->buffer = realloc(b->buffer, b->prefix + b->len + len);
if (!b->buffer)
return -1;
-
+
b->size = b->len + len;
}
-
+
memcpy(b->buffer + b->prefix + b->len, in, len);
b->buffer[b->prefix + b->len + len - 1] = 0;
b->len += len;
-
+
return 0;
}
@@ -143,13 +143,13 @@ int web_buffer_append_json(struct web_buffer *b, json_t *res)
size_t len;
assert(b->state == STATE_INITIALIZED);
-
+
retry: len = json_dumpb(res, b->buffer + b->prefix + b->len, b->size - b->len, 0) + 1;
if (b->size < b->len + len) {
b->buffer = realloc(b->buffer, b->prefix + b->len + len);
if (!b->buffer)
return -1;
-
+
b->size = b->len + len;
goto retry;
}
diff --git a/lib/webmsg.c b/lib/webmsg.c
index 360439c2a..45be95df6 100644
--- a/lib/webmsg.c
+++ b/lib/webmsg.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/plugins/hooks/example_hook.c b/plugins/hooks/example_hook.c
index 9ef71b73f..3eed16ba3 100644
--- a/plugins/hooks/example_hook.c
+++ b/plugins/hooks/example_hook.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
diff --git a/plugins/models/constants.h b/plugins/models/constants.h
index f551ef0e8..4e1bbc6fb 100644
--- a/plugins/models/constants.h
+++ b/plugins/models/constants.h
@@ -1,9 +1,9 @@
/* These constants are defined by RTDS in the component header file */
-#define PI 3.1415926535897932384626433832795 // definition of PI
-#define TWOPI 6.283185307179586476925286766559 // definition of 2.0*PI
-#define E 2.71828182845904523536028747135266 // definition of E
-#define EINV 0.36787944117144232159552377016147 // definition of E Inverse (1/E)
-#define RT2 1.4142135623730950488016887242097 // definition of square root 2.0
-#define RT3 1.7320508075688772935274463415059 // definition of square root 3.0
+#define PI 3.1415926535897932384626433832795 // definition of PI
+#define TWOPI 6.283185307179586476925286766559 // definition of 2.0*PI
+#define E 2.71828182845904523536028747135266 // definition of E
+#define EINV 0.36787944117144232159552377016147 // definition of E Inverse (1/E)
+#define RT2 1.4142135623730950488016887242097 // definition of square root 2.0
+#define RT3 1.7320508075688772935274463415059 // definition of square root 3.0
#define INV_ROOT2 0.70710678118654752440084436210485
\ No newline at end of file
diff --git a/plugins/models/simple_circuit.c b/plugins/models/simple_circuit.c
index e49195081..bb3327130 100644
--- a/plugins/models/simple_circuit.c
+++ b/plugins/models/simple_circuit.c
@@ -30,12 +30,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -112,10 +112,10 @@ void simple_circuit_code() {
/* Update source vector */
AC2 = iC2Hist+vC2Hist*GC2;
Jn = IntfIn+AC2;
-
+
/* Solution of the equation Gn*e=Jn; */
eSS2 = GnInv*Jn;
-
+
/* Post step -> calculate the voltage and current for C2 for next step and set interface output */
vC2Hist= eSS2;
iC2Hist = vC2Hist*GC2-AC2;
diff --git a/src/fpga-bench-overruns.c b/src/fpga-bench-overruns.c
index 0420ec2dd..4fc6b44f0 100644
--- a/src/fpga-bench-overruns.c
+++ b/src/fpga-bench-overruns.c
@@ -45,15 +45,15 @@ static int lapack_generate_workload(int N, double *C)
static int lapack_workload(int N, double *A)
{
- int info = 0;
+ int info = 0;
int lworkspace = N;
- int ipiv[N];
- double workspace[N];
+ int ipiv[N];
+ double workspace[N];
dgetrf_(&N, &N, A, &N, ipiv, &info);
if (info > 0)
error("Failed to pivot matrix");
-
+
dgetri_(&N, A, &N, ipiv, workspace, &lworkspace, &info);
if (info > 0)
error("Failed to LU factorized matrix");
@@ -74,7 +74,7 @@ int fpga_benchmark_overruns(struct fpga_card *c)
float period = 50e-6;
int runs = 1.0 / period;
int overruns;
-
+
info("runs = %u", runs);
switch_connect(c->sw, dm, rtds);
@@ -88,7 +88,7 @@ int fpga_benchmark_overruns(struct fpga_card *c)
FILE *g = fopen(fn, "w");
fprintf(g, "# period = %f\n", period);
fprintf(g, "# runs = %u\n", runs);
-
+
struct dma_mem mem;
ret = dma_alloc(dm, &mem, 0x1000, 0);
if (ret)
@@ -104,7 +104,7 @@ int fpga_benchmark_overruns(struct fpga_card *c)
overruns = 0;
total = 0;
-
+
for (int i = 0; i < 2000; i++) {
dma_read(dm, mem.base_phys, 0x200);
dma_read_complete(dm, NULL, NULL);
@@ -135,7 +135,7 @@ int fpga_benchmark_overruns(struct fpga_card *c)
info("iter = %u clks = %ju overruns = %u", p, total / runs, overruns);
fprintf(g, "%u %ju %u\n", p, total / runs, overruns);
-
+
if (overruns >= runs)
break;
}
diff --git a/src/fpga-bench.c b/src/fpga-bench.c
index 8b1b729fc..8d1c00ff9 100644
--- a/src/fpga-bench.c
+++ b/src/fpga-bench.c
@@ -57,10 +57,10 @@ int fpga_benchmarks(int argc, char *argv[], struct fpga_card *c)
#endif
{ "latency", fpga_benchmark_latency }
};
-
+
if (argc < 2)
error("Usage: fpga benchmark (bench)");
-
+
struct bench *bench = NULL;
for (int i = 0; i < ARRAY_LEN(benchmarks); i++) {
if (strcmp(benchmarks[i].name, argv[1]) == 0) {
@@ -105,10 +105,10 @@ int fpga_benchmark_jitter(struct fpga_card *c)
ret = intc_enable(c->intc, (1 << ip->irq), intc_flags);
if (ret)
error("Failed to enable interrupt");
-
+
float period = 50e-6;
int runs = 300.0 / period;
-
+
int *hist = alloc(8 << 20);
XTmrCtr_SetOptions(xtmr, 0, XTC_INT_MODE_OPTION | XTC_EXT_COMPARE_OPTION | XTC_DOWN_COUNT_OPTION | XTC_AUTO_RELOAD_OPTION);
@@ -120,7 +120,7 @@ int fpga_benchmark_jitter(struct fpga_card *c)
uint64_t cnt = intc_wait(c->intc, ip->irq);
if (cnt != 1)
warn("fail");
-
+
/* Ackowledge IRQ */
XTmrCtr_WriteReg((uintptr_t) c->map + ip->baseaddr, 0, XTC_TCSR_OFFSET, XTmrCtr_ReadReg((uintptr_t) c->map + ip->baseaddr, 0, XTC_TCSR_OFFSET));
@@ -139,7 +139,7 @@ int fpga_benchmark_jitter(struct fpga_card *c)
fclose(g);
free(hist);
-
+
ret = intc_disable(c->intc, (1 << ip->irq));
if (ret)
error("Failed to disable interrupt");
@@ -205,11 +205,11 @@ int fpga_benchmark_datamover(struct fpga_card *c)
dm = list_lookup(&c->ips, dm_name);
if (!dm)
error("Unknown datamover");
-
+
ret = switch_connect(c->sw, dm, dm);
if (ret)
error("Failed to configure switch");
-
+
ret = intc_enable(c->intc, (1 << dm->irq) | (1 << (dm->irq + 1)), intc_flags);
if (ret)
error("Failed to enable interrupt");
@@ -230,7 +230,7 @@ int fpga_benchmark_datamover(struct fpga_card *c)
for (int exp = BENCH_DM_EXP_MIN; exp <= BENCH_DM_EXP_MAX; exp++) {
uint64_t start, stop, total = 0, len = 1 << exp;
-
+
#if BENCH_DM == 1
if (exp > 11)
break; /* FIFO and Simple DMA are limited to 4kb */
@@ -253,7 +253,7 @@ int fpga_benchmark_datamover(struct fpga_card *c)
ret = fifo_write(dm, src.base_virt, len);
if (ret < 0)
error("Failed write to FIFO with len = %zu", len);
-
+
ret = fifo_read(dm, dst.base_virt, dst.len);
if (ret < 0)
error("Failed read from FIFO with len = %zu", len);
@@ -270,21 +270,21 @@ int fpga_benchmark_datamover(struct fpga_card *c)
if (i > BENCH_WARMUP)
total += stop - start;
}
-
+
info("exp %u avg %lu", exp, total / runs);
fprintf(g, "%lu %lu\n", len, total / runs);
}
fclose(g);
-
+
ret = switch_disconnect(c->sw, dm, dm);
if (ret)
error("Failed to configure switch");
-
+
ret = dma_free(dm, &mem);
if (ret)
error("Failed to release DMA memory");
-
+
ret = intc_disable(c->intc, (1 << dm->irq) | (1 << (dm->irq + 1)));
if (ret)
error("Failed to enable interrupt");
@@ -304,7 +304,7 @@ int fpga_benchmark_memcpy(struct fpga_card *c)
fprintf(g, "# bytes cycles\n");
uint32_t dummy = 0;
-
+
for (int exp = BENCH_DM_EXP_MIN; exp <= BENCH_DM_EXP_MAX; exp++) {
uint64_t len = 1 << exp;
uint64_t start, end, total = 0;
@@ -312,13 +312,13 @@ int fpga_benchmark_memcpy(struct fpga_card *c)
for (int i = 0; i < runs + BENCH_WARMUP; i++) {
start = rdtsc();
-
+
for (int j = 0; j < len / 4; j++)
// mapi[j] = j; // write
dummy += mapi[j]; // read
end = rdtsc();
-
+
if (i > BENCH_WARMUP)
total += end - start;
}
diff --git a/src/fpga.c b/src/fpga.c
index 4b137f663..793c01f88 100644
--- a/src/fpga.c
+++ b/src/fpga.c
@@ -3,7 +3,7 @@
* @author Steffen Vogel
* @copyright 2017, Steffen Vogel
**********************************************************************************/
-
+
#include
#include
#include
@@ -38,7 +38,7 @@ void usage()
int main(int argc, char *argv[])
{
int ret;
-
+
struct super_node sn;
struct fpga_card *card;
@@ -59,17 +59,17 @@ int main(int argc, char *argv[])
check: if (optarg == endptr)
error("Failed to parse parse option argument '-%c %s'", c, optarg);
}
-
+
if (argc != optind + 2) {
usage();
exit(EXIT_FAILURE);
}
-
+
char *configfile = argv[optind];
super_node_init(&sn);
super_node_parse_uri(&sn, configfile);
-
+
log_init(&sn.log, sn.log.level, sn.log.facilities);
rt_init(sn.priority, sn.affinity);
memory_init(sn.hugepages);
@@ -78,7 +78,7 @@ check: if (optarg == endptr)
ret = fpga_init(&sn);
if (ret)
error("Failed to initialize FPGA card");
-
+
card = fpga_lookup_card(argv[2]);
if (!card)
error("FPGA card '%s' does not exist", argv[2]);
@@ -92,7 +92,7 @@ check: if (optarg == endptr)
ret = fpga_deinit();
if (ret)
error("Failed to de-initialize FPGA card");
-
+
super_node_destroy(&sn);
return 0;
diff --git a/src/hook.c b/src/hook.c
index f0c35a273..a12d36623 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -49,7 +49,7 @@ static int hook_parse_cli(struct hook *h, char *params[], int paramlen)
int ret;
char *str;
config_setting_t *cfg_root;
-
+
/* Concat all params */
str = NULL;
for (int i = 0; i < paramlen; i++)
@@ -62,7 +62,7 @@ static int hook_parse_cli(struct hook *h, char *params[], int paramlen)
if (ret != CONFIG_TRUE)
error("Failed to parse argument '%s': %s", str, config_error_text(&cfg));
}
-
+
//config_write(&cfg, stdout);
cfg_root = config_root_setting(&cfg);
@@ -96,17 +96,17 @@ static void usage()
int main(int argc, char *argv[])
{
int ret, level;
-
+
size_t cnt, recv;
-
+
/* Default values */
level = V;
cnt = 1;
-
+
struct log log;
struct plugin *p;
struct sample *samples[cnt];
-
+
struct pool q = { .state = STATE_DESTROYED };
struct hook h = { .state = STATE_DESTROYED };
@@ -130,29 +130,29 @@ int main(int argc, char *argv[])
usage();
exit(EXIT_FAILURE);
}
-
+
char *hookstr = argv[optind];
-
+
if (cnt < 1)
error("Vectorize option must be greater than 0");
-
+
log_init(&log, level, LOG_ALL);
log_start(&log);
memory_init(DEFAULT_NR_HUGEPAGES);
-
+
ret = pool_init(&q, 10 * cnt, SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage);
if (ret)
error("Failed to initilize memory pool");
-
-
+
+
p = plugin_lookup(PLUGIN_TYPE_HOOK, hookstr);
if (!p)
error("Unknown hook function '%s'", hookstr);
config_init(&cfg);
-
+
ret = hook_init(&h, &p->hook, NULL);
if (ret)
error("Failed to initialize hook");
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
error("Failed to parse hook config");
hook_start(&h);
-
+
while (!feof(stdin)) {
ret = sample_alloc(&q, samples, cnt);
if (ret != cnt)
@@ -173,27 +173,27 @@ int main(int argc, char *argv[])
ret = sample_io_villas_fscan(stdin, samples[j], NULL);
if (ret < 0)
break;
-
+
samples[j]->ts.received = time_now();
recv++;
}
debug(15, "Read %zu samples from stdin", recv);
-
+
hook_read(&h, samples, &recv);
hook_write(&h, samples, &recv);
-
+
for (int j = 0; j < recv; j++)
sample_io_villas_fprint(stdout, samples[j], SAMPLE_IO_ALL);
fflush(stdout);
-
+
sample_free(samples, cnt);
}
-
+
hook_stop(&h);
hook_destroy(&h);
config_destroy(&cfg);
-
+
sample_free(samples, cnt);
pool_destroy(&q);
diff --git a/src/node.c b/src/node.c
index 039fca9e9..c09916d14 100644
--- a/src/node.c
+++ b/src/node.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -69,11 +69,11 @@ static void usage()
printf("Supported node types:\n");
plugin_dump(PLUGIN_TYPE_NODE);
printf("\n");
-
+
printf("Supported hooks:\n");
plugin_dump(PLUGIN_TYPE_HOOK);
printf("\n");
-
+
printf("Supported API commands:\n");
plugin_dump(PLUGIN_TYPE_API);
printf("\n");
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
#ifdef ENABLE_OPAL_ASYNC
if (argc != 4)
usage(argv[0]);
-
+
char *uri = "opal-shmem.conf";
#else
if (argc == 2) {
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
else if (argc > 2)
usage();
#endif
-
+
info("This is VILLASnode %s (built on %s, %s)", BLD(YEL(BUILDID)),
BLD(MAG(__DATE__)), BLD(MAG(__TIME__)));
diff --git a/src/pipe.c b/src/pipe.c
index 8403c5051..074fb5106 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
@@ -67,17 +67,17 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
pthread_join(recvv.thread, NULL);
pool_destroy(&recvv.pool);
}
-
+
if (sendd.started) {
pthread_cancel(sendd.thread);
pthread_join(sendd.thread, NULL);
pool_destroy(&sendd.pool);
}
-
+
ret = super_node_stop(&sn);
if (ret)
error("Failed to stop super-node");
-
+
super_node_destroy(&sn);
info(GRN("Goodbye!"));
@@ -107,14 +107,14 @@ static void * send_loop(void *ctx)
if (!sendd.enabled)
return NULL;
-
+
sendd.started = true;
-
+
/* Initialize memory */
ret = pool_init(&sendd.pool, LOG2_CEIL(node->vectorize), SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage);
if (ret < 0)
error("Failed to allocate memory for receive pool.");
-
+
ret = sample_alloc(&sendd.pool, smps, node->vectorize);
if (ret < 0)
error("Failed to get %u samples out of send pool (%d).", node->vectorize, ret);
@@ -151,17 +151,17 @@ static void * recv_loop(void *ctx)
{
int ret;
struct sample *smps[node->vectorize];
-
+
if (!recvv.enabled)
return NULL;
recvv.started = true;
-
+
/* Initialize memory */
ret = pool_init(&recvv.pool, LOG2_CEIL(node->vectorize), SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage);
if (ret < 0)
error("Failed to allocate memory for receive pool.");
-
+
ret = sample_alloc(&recvv.pool, smps, node->vectorize);
if (ret < 0)
error("Failed to get %u samples out of receive pool (%d).", node->vectorize, ret);
@@ -219,21 +219,21 @@ int main(int argc, char *argv[])
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
}
}
-
+
if (argc != optind + 2) {
usage();
exit(EXIT_FAILURE);
}
-
+
char *configfile = argv[optind];
char *nodestr = argv[optind+1];
log_init(&sn.log, level, LOG_ALL);
log_start(&sn.log);
-
+
super_node_init(&sn);
super_node_parse_uri(&sn, configfile);
-
+
memory_init(sn.hugepages);
signals_init(quit);
rt_init(sn.priority, sn.affinity);
@@ -254,7 +254,7 @@ int main(int argc, char *argv[])
ret = node_type_start(node->_vt, &sn);
if (ret)
error("Failed to intialize node type: %s", node_name(node));
-
+
ret = node_check(node);
if (ret)
error("Invalid node configuration");
diff --git a/src/signal.c b/src/signal.c
index 280e7c419..fa4a78d6a 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -11,12 +11,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
{
struct log log;
struct timespec start, now;
-
+
enum {
MODE_RT,
MODE_NON_RT
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
double running;
int type = TYPE_MIXED;
int values = 1;
- int limit = -1;
+ int limit = -1;
int counter, tfd, steps, level = V;
/* Parse optional command line arguments */
@@ -122,9 +122,9 @@ int main(int argc, char *argv[])
usage();
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
}
-
+
continue;
-
+
check: if (optarg == endptr)
error("Failed to parse parse option argument '-%c %s'", c, optarg);
}
@@ -133,9 +133,9 @@ check: if (optarg == endptr)
usage();
exit(EXIT_FAILURE);
}
-
+
char *typestr = argv[optind];
-
+
/* Parse signal type */
if (!strcmp(typestr, "random"))
type = TYPE_RANDOM;
@@ -151,7 +151,7 @@ check: if (optarg == endptr)
type = TYPE_MIXED;
else
error("Invalid signal type: %s", typestr);
-
+
log_init(&log, level, LOG_ALL);
/* Allocate memory for message buffer */
@@ -181,10 +181,10 @@ check: if (optarg == endptr)
}
else {
struct timespec offset;
-
+
running = counter * 1.0 / rate;
offset = time_from_double(running);
-
+
now = time_add(&start, &offset);
}
@@ -193,7 +193,7 @@ check: if (optarg == endptr)
s->length = values;
for (int i = 0; i < values; i++) {
- int rtype = (type != TYPE_MIXED) ? type : i % 4;
+ int rtype = (type != TYPE_MIXED) ? type : i % 4;
switch (rtype) {
case TYPE_RANDOM: s->data[i].f += box_muller(0, stddev); break;
case TYPE_SINE: s->data[i].f = ampl * sin(running * freq * 2 * M_PI); break;
@@ -202,17 +202,17 @@ check: if (optarg == endptr)
case TYPE_RAMP: s->data[i].f = fmod(counter, rate / freq); /** @todo send as integer? */ break;
}
}
-
+
sample_io_villas_fprint(stdout, s, SAMPLE_IO_ALL & ~SAMPLE_IO_OFFSET);
fflush(stdout);
-
+
/* Throttle output if desired */
if (mode == MODE_RT) {
/* Block until 1/p->rate seconds elapsed */
steps = timerfd_wait(tfd);
if (steps > 1)
warn("Missed steps: %u", steps);
-
+
counter += steps;
}
else
diff --git a/src/test-cmp.c b/src/test-cmp.c
index 7c802c8ae..3c4f5530e 100644
--- a/src/test-cmp.c
+++ b/src/test-cmp.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -54,7 +54,7 @@ void usage()
printf(" 5 data is not equal\n");
printf("\n");
- print_copyright();
+ print_copyright();
}
int main(int argc, char *argv[])
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
struct log log;
struct pool pool = { .state = STATE_DESTROYED };
struct sample *samples[2];
-
+
struct {
int flags;
char *path;
@@ -94,12 +94,12 @@ int main(int argc, char *argv[])
check: if (optarg == endptr)
error("Failed to parse parse option argument '-%c %s'", c, optarg);
}
-
+
if (argc != optind + 2) {
usage();
exit(EXIT_FAILURE);
}
-
+
f1.path = argv[optind];
f2.path = argv[optind + 1];
@@ -108,10 +108,10 @@ check: if (optarg == endptr)
pool_init(&pool, 1024, SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_heap);
sample_alloc(&pool, samples, 2);
-
+
f1.sample = samples[0];
f2.sample = samples[1];
-
+
f1.handle = fopen(f1.path, "r");
if (!f1.handle)
serror("Failed to open file: %s", f1.path);
@@ -119,16 +119,16 @@ check: if (optarg == endptr)
f2.handle = fopen(f2.path, "r");
if (!f2.handle)
serror("Failed to open file: %s", f2.path);
-
+
while (!feof(f1.handle) && !feof(f2.handle)) {
ret = sample_io_villas_fscan(f1.handle, f1.sample, &f1.flags);
if (ret < 0 && !feof(f1.handle))
goto out;
-
+
ret = sample_io_villas_fscan(f2.handle, f2.sample, &f2.flags);
if (ret < 0 && !feof(f2.handle))
goto out;
-
+
/* EOF is only okay if both files are at the end */
if (feof(f1.handle) || feof(f2.handle)) {
if (!(feof(f1.handle) && feof(f2.handle))) {
@@ -146,21 +146,21 @@ check: if (optarg == endptr)
goto out;
}
}
-
+
/* Compare timestamp */
if (time_delta(&f1.sample->ts.origin, &f2.sample->ts.origin) > epsilon) {
printf("ts.origin: %f != %f\n", time_to_double(&f1.sample->ts.origin), time_to_double(&f2.sample->ts.origin));
ret = 3;
goto out;
}
-
+
/* Compare data */
if (f1.sample->length != f2.sample->length) {
printf("length: %d != %d\n", f1.sample->length, f2.sample->length);
ret = 4;
goto out;
}
-
+
for (int i = 0; i < f1.sample->length; i++) {
if (fabs(f1.sample->data[i].f - f2.sample->data[i].f) > epsilon) {
printf("data[%d]: %f != %f\n", i, f1.sample->data[i].f, f2.sample->data[i].f);
@@ -169,14 +169,14 @@ check: if (optarg == endptr)
}
}
}
-
+
ret = 0;
-
+
out: sample_free(samples, 2);
fclose(f1.handle);
fclose(f2.handle);
-
+
pool_destroy(&pool);
return ret;
diff --git a/src/test-rtt.c b/src/test-rtt.c
index f92d8bd9b..3c52170ed 100644
--- a/src/test-rtt.c
+++ b/src/test-rtt.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -114,20 +114,20 @@ int main(int argc, char *argv[])
check: if (optarg == endptr)
error("Failed to parse parse option argument '-%c %s'", c, optarg);
}
-
+
if (argc != optind + 2) {
usage();
exit(EXIT_FAILURE);
}
-
+
char *configfile = argv[optind];
char *nodestr = argv[optind + 1];
-
+
log_init(&sn.log, V, LOG_ALL);
-
+
super_node_init(&sn);
super_node_parse_uri(&sn, configfile);
-
+
signals_init(quit);
rt_init(sn.priority, sn.affinity);
memory_init(sn.hugepages);
@@ -143,7 +143,7 @@ check: if (optarg == endptr)
node_stop(node);
node_type_stop(node->_vt);
-
+
super_node_destroy(&sn);
return 0;
@@ -151,23 +151,23 @@ check: if (optarg == endptr)
void test_rtt() {
struct hist hist;
-
+
struct timespec send, recv;
struct sample *smp_send = alloc(SAMPLE_LEN(2));
struct sample *smp_recv = alloc(SAMPLE_LEN(2));
-
+
hist_init(&hist, low, high, res);
/* Print header */
fprintf(stdout, "%17s%5s%10s%10s%10s%10s%10s\n", "timestamp", "seq", "rtt", "min", "max", "mean", "stddev");
- while (running && (count < 0 || count--)) {
+ while (running && (count < 0 || count--)) {
clock_gettime(CLOCK_ID, &send);
node_write(node, &smp_send, 1); /* Ping */
node_read(node, &smp_recv, 1); /* Pong */
-
+
clock_gettime(CLOCK_ID, &recv);
double rtt = time_delta(&recv, &send);
@@ -179,7 +179,7 @@ void test_rtt() {
smp_send->sequence++;
- fprintf(stdout, "%10lu.%06lu%5u%10.3f%10.3f%10.3f%10.3f%10.3f\n",
+ fprintf(stdout, "%10lu.%06lu%5u%10.3f%10.3f%10.3f%10.3f%10.3f\n",
recv.tv_sec, recv.tv_nsec / 1000, smp_send->sequence,
1e3 * rtt, 1e3 * hist.lowest, 1e3 * hist.highest,
1e3 * hist_mean(&hist), 1e3 * hist_stddev(&hist));
diff --git a/src/test-shmem.c b/src/test-shmem.c
index 5d978b784..06b38fab4 100644
--- a/src/test-shmem.c
+++ b/src/test-shmem.c
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -52,17 +52,17 @@ void quit(int sig)
int main(int argc, char* argv[])
{
struct log log;
-
+
log_init(&log, V, LOG_ALL);
log_start(&log);
-
+
int readcnt, writecnt, avail;
if (argc != 3) {
usage();
return 1;
}
-
+
char *object = argv[1];
int vectorize = atoi(argv[2]);
@@ -73,7 +73,7 @@ int main(int argc, char* argv[])
signal(SIGINT, quit);
signal(SIGTERM, quit);
struct sample *insmps[vectorize], *outsmps[vectorize];
-
+
while (1) {
readcnt = shmem_shared_read(shared, insmps, vectorize);
if (readcnt == -1) {
@@ -101,7 +101,7 @@ int main(int argc, char* argv[])
writecnt = shmem_shared_write(shared, outsmps, avail);
if (writecnt < avail)
warn("Short write");
-
+
info("Read / Write: %d / %d", readcnt, writecnt);
}
}
diff --git a/tests/integration-tests.sh b/tests/integration-tests.sh
index 89df308e3..68af21a6f 100755
--- a/tests/integration-tests.sh
+++ b/tests/integration-tests.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
@@ -75,7 +75,7 @@ for TEST in ${TESTS}; do
else
${TEST}
fi
-
+
RC=$?
if (( $RC != 0 )); then
diff --git a/tests/integration/api-config.sh b/tests/integration/api-config.sh
index 426cb1931..3480464eb 100755
--- a/tests/integration/api-config.sh
+++ b/tests/integration/api-config.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/api-nodes.sh b/tests/integration/api-nodes.sh
index a79bf4ad9..5886b5822 100755
--- a/tests/integration/api-nodes.sh
+++ b/tests/integration/api-nodes.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
@@ -36,7 +36,7 @@ nodes = {
testnode2 = {
type = "socket";
dummy = "value2";
-
+
local = "*:12001";
remote = "localhost:12000";
}
diff --git a/tests/integration/hook-convert.sh b/tests/integration/hook-convert.sh
index b1928e5ec..8625cffab 100755
--- a/tests/integration/hook-convert.sh
+++ b/tests/integration/hook-convert.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-decimate.sh b/tests/integration/hook-decimate.sh
index 8f2903b3b..7a85cc42e 100755
--- a/tests/integration/hook-decimate.sh
+++ b/tests/integration/hook-decimate.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-drop.sh b/tests/integration/hook-drop.sh
index 148e5559e..29959949e 100755
--- a/tests/integration/hook-drop.sh
+++ b/tests/integration/hook-drop.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-map.sh b/tests/integration/hook-map.sh
index 29fc7def9..1a52a8c20 100755
--- a/tests/integration/hook-map.sh
+++ b/tests/integration/hook-map.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-shift_seq.sh b/tests/integration/hook-shift_seq.sh
index d4f8ee2d7..8aedc9e20 100755
--- a/tests/integration/hook-shift_seq.sh
+++ b/tests/integration/hook-shift_seq.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-shift_ts.sh b/tests/integration/hook-shift_ts.sh
index f99ef0238..869ece6db 100755
--- a/tests/integration/hook-shift_ts.sh
+++ b/tests/integration/hook-shift_ts.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-skip_first.sh b/tests/integration/hook-skip_first.sh
index b345e7107..7b0892c53 100755
--- a/tests/integration/hook-skip_first.sh
+++ b/tests/integration/hook-skip_first.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/hook-skip_first2.sh b/tests/integration/hook-skip_first2.sh
index 22bc4e930..4ea001ffb 100755
--- a/tests/integration/hook-skip_first2.sh
+++ b/tests/integration/hook-skip_first2.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/integration/node-loopback.sh b/tests/integration/node-loopback.sh
index 6577626a6..01472c547 100755
--- a/tests/integration/node-loopback.sh
+++ b/tests/integration/node-loopback.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
@@ -32,7 +32,7 @@ function prefix() {
pipe) P=$'\\\e[93mpipe\\\e[39m: ' ;;
cmp) P=$'\\\e[35mcmp\\\e[39m: ' ;;
esac
-
+
sed -e "s/^/$P/"
}
@@ -45,7 +45,7 @@ nodes = {
local = "*:12000";
remote = "127.0.0.1:12001"
}
-
+
node2 = {
type = "socket";
layer = "udp";
diff --git a/tests/integration/pipe-file-advio.sh b/tests/integration/pipe-file-advio.sh
index ef1fad15f..82b5f124c 100755
--- a/tests/integration/pipe-file-advio.sh
+++ b/tests/integration/pipe-file-advio.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
@@ -32,7 +32,7 @@ cat > ${CONFIG_FILE} <.
##################################################################################
@@ -31,7 +31,7 @@ nodes = {
node1 = {
type = "socket";
layer = "udp";
-
+
local = "*:12000";
remote = "127.0.0.1:12000"
}
diff --git a/tests/integration/test-cmp.sh b/tests/integration/test-cmp.sh
index 76181ca1f..fbd38b95b 100755
--- a/tests/integration/test-cmp.sh
+++ b/tests/integration/test-cmp.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tests/unit/advio.c b/tests/unit/advio.c
index 3cfc4ef7e..b53ac726a 100644
--- a/tests/unit/advio.c
+++ b/tests/unit/advio.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -45,7 +45,7 @@ Test(advio, download)
len = afread(buffer, 1, sizeof(buffer), af);
cr_assert_gt(len, 0, "len=%zu, feof=%u", len, afeof(af));
-
+
cr_assert_arr_eq(buffer, expect, sizeof(expect));
ret = afclose(af);
@@ -57,33 +57,33 @@ Test(advio, upload)
AFILE *af;
int ret;
size_t len;
-
+
char upload[64];
char buffer[64];
-
+
/* Get some random data to upload */
len = read_random(upload, sizeof(upload));
cr_assert_eq(len, sizeof(upload));
-
+
/* Open file for writing */
af = afopen(BASE_URI "/upload", "w+");
cr_assert(af, "Failed to download file");
-
+
len = afwrite(upload, 1, sizeof(upload), af);
cr_assert_eq(len, sizeof(upload));
-
+
ret = afclose(af);
cr_assert_eq(ret, 0, "Failed to close/upload file");
-
+
/* Open for reading and comparison */
af = afopen(BASE_URI "/upload", "r");
cr_assert(af, "Failed to download file");
-
+
len = afread(buffer, 1, sizeof(upload), af);
cr_assert_eq(len, sizeof(upload));
-
+
cr_assert_arr_eq(buffer, upload, len);
-
+
ret = afclose(af);
cr_assert(ret == 0, "Failed to close file");
}
@@ -106,7 +106,7 @@ Test(advio, append)
/* The append file might already exist and be not empty from a previous run. */
ret = ftruncate(afileno(af), 0);
cr_assert_eq(ret, 0);
-
+
char c;
fseek(af->file, 0, SEEK_SET);
if (af->file) {
@@ -123,20 +123,20 @@ Test(advio, append)
/* Open file for writing second chunk */
af = afopen(BASE_URI "/append", "a");
cr_assert(af, "Failed to download file");
-
+
len = afwrite(append2, 1, sizeof(append2), af);
cr_assert_eq(len, sizeof(append2));
-
+
ret = afclose(af);
cr_assert_eq(ret, 0, "Failed to close/upload file");
-
+
/* Open for reading and comparison */
af = afopen(BASE_URI "/append", "r");
cr_assert(af, "Failed to download file");
-
+
len = afread(buffer, 1, sizeof(buffer), af);
cr_assert_eq(len, sizeof(buffer));
-
+
ret = afclose(af);
cr_assert(ret == 0, "Failed to close file");
diff --git a/tests/unit/config_json.c b/tests/unit/config_json.c
index 9b4b8947f..3034c8a34 100644
--- a/tests/unit/config_json.c
+++ b/tests/unit/config_json.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -63,25 +63,25 @@ Test(utils, config_to_json)
config_t cfg;
config_setting_t *cfg_root;
json_t *json;
-
+
config_init(&cfg);
-
+
ret = config_read_string(&cfg, cfg_example);
cr_assert_eq(ret, CONFIG_TRUE);
-
+
cfg_root = config_root_setting(&cfg);
-
+
json = config_to_json(cfg_root);
cr_assert_not_null(json);
-
+
char *str = json_dumps(json, JSON_INDENT(2));
-
+
//printf("%s\n", str);
-
+
json_decref(json);
-
+
cr_assert_str_eq(str, json_example);
-
+
config_destroy(&cfg);
}
@@ -90,27 +90,27 @@ Test(utils, json_to_config)
config_t cfg;
config_setting_t *cfg_root;
json_t *json;
-
+
/* For config_write() */
FILE *f;
char str[1024];
-
+
config_init(&cfg);
cfg_root = config_root_setting(&cfg);
-
+
json = json_loads(json_example, 0, NULL);
cr_assert_not_null(json);
-
+
json_to_config(json, cfg_root);
-
+
//config_write(&cfg, stdout);
f = fmemopen(str, sizeof(str), "w+");
config_write(&cfg, f);
fclose(f);
-
+
cr_assert_str_eq(str, cfg_example);
-
+
json_decref(json);
}
diff --git a/tests/unit/fpga.c b/tests/unit/fpga.c
index c4a04cca7..5e30f8a0e 100644
--- a/tests/unit/fpga.c
+++ b/tests/unit/fpga.c
@@ -40,22 +40,22 @@ static void init()
{
int ret;
config_setting_t *cfg_root;
-
+
ret = super_node_init(&sn);
cr_assert_eq(ret, 0, "Failed to initialize Supernode");
-
+
ret = super_node_parse_uri(&sn, TEST_CONFIG);
cr_assert_eq(ret, 0, "Failed to parse configuration");
ret = super_node_check(&sn);
cr_assert_eq(ret, 0, "Failed to check configuration");
-
+
cfg_root = config_root_setting(&sn.cfg);
cr_assert_neq(cfg_root, NULL);
ret = pci_init(&pci);
cr_assert_eq(ret, 0, "Failed to initialize PCI sub-system");
-
+
ret = vfio_init(&vc);
cr_assert_eq(ret, 0, "Failed to initiliaze VFIO sub-system");
@@ -77,7 +77,7 @@ static void fini()
ret = fpga_card_destroy(card);
cr_assert_eq(ret, 0, "Failed to de-initilize FPGA");
-
+
super_node_destroy(&sn);
}
@@ -133,10 +133,10 @@ Test(fpga, xsg, .description = "XSG: multiply_add")
p = list_lookup(&model->parameters, "factor");
if (!p)
error("Missing parameter 'factor' for model '%s'", ip->name);
-
+
ret = model_param_read(p, &factor);
cr_assert_eq(ret, 0, "Failed to read parameter 'factor' from model '%s'", ip->name);
-
+
info("Model param: factor = %f", factor);
ret = switch_connect(card->sw, dma, ip);
@@ -147,7 +147,7 @@ Test(fpga, xsg, .description = "XSG: multiply_add")
ret = dma_alloc(dma, &mem, 0x1000, 0);
cr_assert_eq(ret, 0, "Failed to allocate DMA memory");
-
+
float *src = (float *) mem.base_virt;
float *dst = (float *) mem.base_virt + 0x800;
@@ -178,7 +178,7 @@ Test(fpga, hls_dft, .description = "HLS: hls_dft")
{
int ret;
struct fpga_ip *hls, *rtds;
-
+
rtds = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { "acs.eonerc.rwth-aachen.de", "user", "rtds_axis", NULL });
hls = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { NULL, "hls", "hls_dft", NULL });
@@ -187,7 +187,7 @@ Test(fpga, hls_dft, .description = "HLS: hls_dft")
ret = intc_enable(card->intc, (1 << rtds->irq), 0);
cr_assert_eq(ret, 0, "Failed to enable interrupt");
-
+
ret = switch_connect(card->sw, rtds, hls);
cr_assert_eq(ret, 0, "Failed to configure switch");
@@ -203,14 +203,14 @@ Test(fpga, hls_dft, .description = "HLS: hls_dft")
int len = 2000;
int NSAMPLES = 400;
float src[len], dst[len];
-
+
for (int i = 0; i < len; i++) {
- src[i] = 4 + 5.0 * sin(2.0 * M_PI * 1 * i / NSAMPLES) +
- 2.0 * sin(2.0 * M_PI * 2 * i / NSAMPLES) +
- 1.0 * sin(2.0 * M_PI * 5 * i / NSAMPLES) +
- 0.5 * sin(2.0 * M_PI * 9 * i / NSAMPLES) +
+ src[i] = 4 + 5.0 * sin(2.0 * M_PI * 1 * i / NSAMPLES) +
+ 2.0 * sin(2.0 * M_PI * 2 * i / NSAMPLES) +
+ 1.0 * sin(2.0 * M_PI * 5 * i / NSAMPLES) +
+ 0.5 * sin(2.0 * M_PI * 9 * i / NSAMPLES) +
0.2 * sin(2.0 * M_PI * 15 * i / NSAMPLES);
-
+
fifo_write()
}
#endif
@@ -272,9 +272,9 @@ Test(fpga, dma, .description = "DMA")
if (fpga_vlnv_cmp(&dm->vlnv, &(struct fpga_vlnv) { "xilinx.com", "ip", "axi_dma", NULL }))
continue; /* skip non DMA IP cores */
-
+
struct dma *dma = dm->_vd;
-
+
/* Simple DMA can only transfer up to 4 kb due to
* PCIe page size burst limitation */
ssize_t len2, len = dma->inst.HasSg ? 64 << 20 : 1 << 2;
@@ -298,7 +298,7 @@ Test(fpga, dma, .description = "DMA")
ret = switch_connect(card->sw, dm, dm);
cr_assert_eq(ret, 0, "Failed to configure switch");
-
+
/* Start transfer */
ret = dma_ping_pong(dm, src.base_phys, dst.base_phys, dst.len);
cr_assert_eq(ret, 0, "DMA ping pong failed");
@@ -312,7 +312,7 @@ Test(fpga, dma, .description = "DMA")
ret = intc_disable(card->intc, (1 << irq_mm2s) | (1 << irq_s2mm));
cr_assert_eq(ret, 0, "Failed to disable interrupt");
-
+
ret = dma_free(dm, &mem);
cr_assert_eq(ret, 0, "Failed to release DMA memory");
}
@@ -328,9 +328,9 @@ Test(fpga, timer, .description = "Timer Counter")
ip = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { "xilinx.com", "ip", "axi_timer", NULL });
cr_assert(ip);
-
+
tmr = ip->_vd;
-
+
XTmrCtr *xtmr = &tmr->inst;
ret = intc_enable(card->intc, (1 << ip->irq), 0);
@@ -364,8 +364,8 @@ Test(fpga, rtds_rtt, .description = "RTDS: tight rtt")
/* Get IP cores */
rtds = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { "acs.eonerc.rwth-aachen.de", "user", "rtds_axis", NULL });
cr_assert(rtds);
-
- ip = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { "xilinx.com", "ip", "axi_dma", NULL });
+
+ ip = fpga_vlnv_lookup(&card->ips, &(struct fpga_vlnv) { "xilinx.com", "ip", "axi_dma", NULL });
cr_assert(ip);
ret = switch_connect(card->sw, rtds, ip);
@@ -378,7 +378,7 @@ Test(fpga, rtds_rtt, .description = "RTDS: tight rtt")
cr_assert_eq(ret, 0, "Failed to allocate DMA memory");
while (1) {
-
+
ret = dma_read(ip, buf.base_phys, buf.len);
cr_assert_eq(ret, 0, "Failed to start DMA read: %d", ret);
@@ -387,7 +387,7 @@ Test(fpga, rtds_rtt, .description = "RTDS: tight rtt")
ret = dma_write(ip, buf.base_phys, recvlen);
cr_assert_eq(ret, 0, "Failed to start DMA write: %d", ret);
-
+
ret = dma_write_complete(ip, NULL, NULL);
cr_assert_eq(ret, 0, "Failed to complete DMA write: %d", ret);
}
@@ -397,7 +397,7 @@ Test(fpga, rtds_rtt, .description = "RTDS: tight rtt")
ret = switch_disconnect(card->sw, ip, rtds);
cr_assert_eq(ret, 0, "Failed to configure switch");
-
+
ret = dma_free(ip, &buf);
cr_assert_eq(ret, 0, "Failed to release DMA memory");
}
\ No newline at end of file
diff --git a/tests/unit/hist.c b/tests/unit/hist.c
index e9de21c3b..dccc15dda 100644
--- a/tests/unit/hist.c
+++ b/tests/unit/hist.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -33,19 +33,19 @@ const int hist_result[] = {};
Test(hist, simple) {
struct hist h;
int ret;
-
+
ret = hist_init(&h, -100, 100, 1);
cr_assert_eq(ret, 0);
-
+
for (int i = 0; i < ARRAY_LEN(test_data); i++)
hist_put(&h, test_data[i]);
-
+
cr_assert_float_eq(hist_mean(&h), 5.5, 1e-6);
cr_assert_float_eq(hist_var(&h), 9.1666, 1e-3,);
cr_assert_float_eq(hist_stddev(&h), 3.027650, 1e-6);
-
+
// for (int i = 0; i < ARRAY_LEN(hist_result); i++)
// cr_assert_eq()
-
+
hist_destroy(&h);
}
\ No newline at end of file
diff --git a/tests/unit/kernel.c b/tests/unit/kernel.c
index ff95b0bc3..6f05b184c 100644
--- a/tests/unit/kernel.c
+++ b/tests/unit/kernel.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -32,10 +32,10 @@ Test(kernel, sizes)
sz = kernel_get_page_size();
cr_assert_eq(sz, 1 << 12);
-
+
sz = kernel_get_hugepage_size();
cr_assert(sz == 1 << 22 || sz == 1 << 21);
-
+
sz = kernel_get_cacheline_size();
cr_assert_eq(sz, 64);
}
@@ -43,16 +43,16 @@ Test(kernel, sizes)
Test(kernel, hugepages)
{
int ret;
-
+
ret = kernel_set_nr_hugepages(25);
cr_assert_eq(ret, 0);
-
+
ret = kernel_get_nr_hugepages();
cr_assert_eq(ret, 25);
ret = kernel_set_nr_hugepages(10);
cr_assert_eq(ret, 0);
-
+
ret = kernel_get_nr_hugepages();
cr_assert_eq(ret, 10);
@@ -66,7 +66,7 @@ Test(kernel, version)
ret = kernel_get_version(&ver);
cr_assert_eq(ret, 0);
-
+
ret = version_cmp(&ver, &(struct version) { 100, 5 });
cr_assert_lt(ret, 0);
@@ -77,7 +77,7 @@ Test(kernel, version)
Test(kernel, module)
{
int ret;
-
+
ret = kernel_module_loaded("nf_nat");
cr_assert_eq(ret, 0);
diff --git a/tests/unit/list.c b/tests/unit/list.c
index 9b51e681e..09f329219 100644
--- a/tests/unit/list.c
+++ b/tests/unit/list.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,46 +37,46 @@ struct data {
Test(list, list_lookup)
{
struct list l = { .state = STATE_DESTROYED };
-
+
list_init(&l);
-
+
for (int i = 0; i < ARRAY_LEN(nouns); i++) {
struct data *d = malloc(sizeof(struct data));
-
+
d->tag = nouns[i];
d->data = i;
-
+
list_push(&l, d);
}
-
+
struct data *found = list_lookup(&l, "woman");
-
+
cr_assert_eq(found->data, 13);
-
+
list_destroy(&l, NULL, true);
}
Test(list, list_search)
{
struct list l = { .state = STATE_DESTROYED };
-
+
list_init(&l);
-
+
/* Fill list */
for (int i = 0; i < ARRAY_LEN(nouns); i++)
list_push(&l, nouns[i]);
-
+
cr_assert_eq(list_length(&l), ARRAY_LEN(nouns));
/* Declare on stack! */
char positive[] = "woman";
char negative[] = "dinosaurrier";
-
+
char *found = list_search(&l, (cmp_cb_t) strcmp, positive);
cr_assert_not_null(found);
cr_assert_eq(found, nouns[13], "found = %p, nouns[13] = %p", found, nouns[13]);
cr_assert_str_eq(found, positive);
-
+
char *not_found = (char *) list_search(&l, (cmp_cb_t) strcmp, negative);
cr_assert_null(not_found);
@@ -90,9 +90,9 @@ struct content {
static int dtor(void *ptr)
{
struct content *elm = (struct content *) ptr;
-
+
elm->destroyed = 1;
-
+
return 0;
}
@@ -100,12 +100,12 @@ Test(list, destructor)
{
struct list l = { .state = STATE_DESTROYED };
struct content elm = { .destroyed = 0 };
-
+
list_init(&l);
list_push(&l, &elm);
-
+
cr_assert_eq(list_length(&l), 1);
-
+
list_destroy(&l, dtor, false);
cr_assert_eq(elm.destroyed, 1);
@@ -120,12 +120,12 @@ Test(list, basics)
intptr_t i;
int ret;
struct list l = { .state = STATE_DESTROYED };
-
+
list_init(&l);
-
+
for (i = 0; i < 100; i++) {
cr_assert_eq(list_length(&l), i);
-
+
list_push(&l, (void *) i);
}
@@ -138,21 +138,21 @@ Test(list, basics)
cr_assert_eq(k, (void *) i++);
}
-
+
list_sort(&l, compare); /* Reverse list */
-
+
for (size_t j = 0, i = 99; j < list_length(&l); j++) {
void *k = list_at(&l, j);
-
+
cr_assert_eq(k, (void *) i, "Is %p, expected %p", i, k);
i--;
}
ret = list_contains(&l, (void *) 55);
cr_assert(ret);
-
+
list_remove(&l, (void *) 55);
-
+
ret = list_contains(&l, (void *) 55);
cr_assert(!ret);
diff --git a/tests/unit/log.c b/tests/unit/log.c
index e6b97a6f8..9c8c00c62 100644
--- a/tests/unit/log.c
+++ b/tests/unit/log.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -55,13 +55,13 @@ ParameterizedTestParameters(log, facility_expression)
{ "!all", 0 },
{ "", 0 }
};
-
+
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
}
ParameterizedTest(struct param *p, log, facility_expression, .init = init, .fini = fini)
{
log_set_facility_expression(&l, p->expression);
-
+
cr_assert_eq(l.facilities, p->expected, "log.faciltities is %#lx not %#lx", l.facilities, p->expected);
}
\ No newline at end of file
diff --git a/tests/unit/main.c b/tests/unit/main.c
index 18fd7d0c0..adeec8a33 100644
--- a/tests/unit/main.c
+++ b/tests/unit/main.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
error("Failed to initialize logging sub-system");
return ret;
}
-
+
ret = memory_init(DEFAULT_NR_HUGEPAGES);
if (ret) {
error("Failed to initialize memory sub-system");
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
/* Run criterion tests */
tests = criterion_initialize();
-
+
ret = criterion_handle_args(argc, argv, true);
if (ret)
ret = !criterion_run_all_tests(tests);
diff --git a/tests/unit/mapping.c b/tests/unit/mapping.c
index d8d7aa673..42b96f4eb 100644
--- a/tests/unit/mapping.c
+++ b/tests/unit/mapping.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -28,12 +28,12 @@ Test(mapping, parse)
{
int ret;
struct mapping_entry m;
-
+
ret = mapping_entry_parse_str(&m, "ts.origin");
cr_assert_eq(ret, 0);
cr_assert_eq(m.type, MAPPING_TYPE_TIMESTAMP);
cr_assert_eq(m.timestamp.id, MAPPING_TIMESTAMP_ORIGIN);
-
+
ret = mapping_entry_parse_str(&m, "hdr.sequence");
cr_assert_eq(ret, 0);
cr_assert_eq(m.type, MAPPING_TYPE_HEADER);
@@ -44,7 +44,7 @@ Test(mapping, parse)
cr_assert_eq(m.type, MAPPING_TYPE_STATS);
cr_assert_eq(m.stats.id, STATS_OWD);
cr_assert_eq(m.stats.type, MAPPING_STATS_TYPE_MEAN);
-
+
ret = mapping_entry_parse_str(&m, "data[1-2]");
cr_assert_eq(ret, 0);
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
@@ -62,7 +62,7 @@ Test(mapping, parse)
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
cr_assert_eq(m.data.offset, 22);
cr_assert_eq(m.length, 1);
-
+
ret = mapping_entry_parse_str(&m, "data[]");
cr_assert_neq(ret, 0);
@@ -72,7 +72,7 @@ Test(mapping, parse)
/* Missing parts */
ret = mapping_entry_parse_str(&m, "stats.owd");
cr_assert_neq(ret, 0);
-
+
ret = mapping_entry_parse_str(&m, "data");
cr_assert_neq(ret, 0);
@@ -83,7 +83,7 @@ Test(mapping, parse)
/* Check for superfluous chars at the end */
ret = mapping_entry_parse_str(&m, "stats.ts.origin.bla");
cr_assert_neq(ret, 0);
-
+
ret = mapping_entry_parse_str(&m, "stats.ts.origin.");
cr_assert_neq(ret, 0);
diff --git a/tests/unit/memory.c b/tests/unit/memory.c
index ffcb147e9..f0e222758 100644
--- a/tests/unit/memory.c
+++ b/tests/unit/memory.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -37,10 +37,10 @@ TheoryDataPoints(memory, aligned) = {
Theory((size_t len, size_t align, struct memtype *m), memory, aligned) {
int ret;
void *ptr;
-
+
ptr = memory_alloc_aligned(m, len, align);
cr_assert_neq(ptr, NULL, "Failed to allocate memory");
-
+
cr_assert(IS_ALIGNED(ptr, align));
if (m == &memtype_hugepage) {
@@ -54,7 +54,7 @@ Theory((size_t len, size_t align, struct memtype *m), memory, aligned) {
Test(memory, manager) {
size_t total_size;
size_t max_block;
-
+
int ret;
void *p, *p1, *p2, *p3;
struct memtype *m;
@@ -64,7 +64,7 @@ Test(memory, manager) {
p = memory_alloc(&memtype_heap, total_size);
cr_assert_not_null(p);
-
+
m = memtype_managed_init(p, total_size);
cr_assert_not_null(m);
diff --git a/tests/unit/pool.c b/tests/unit/pool.c
index 79aecbab3..3f374eed4 100644
--- a/tests/unit/pool.c
+++ b/tests/unit/pool.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -43,7 +43,7 @@ ParameterizedTestParameters(pool, basic)
{ 1, 4, 8192, &memtype_hugepage },
{ 1, 1 << 13, 4, &memtype_heap }
};
-
+
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
}
@@ -56,12 +56,12 @@ ParameterizedTest(struct param *p, pool, basic)
ret = pool_init(&pool, p->pool_size, p->block_size, p->memtype);
cr_assert_eq(ret, 0, "Failed to create pool");
-
+
ptr = pool_get(&pool);
cr_assert_neq(ptr, NULL);
-
+
memset(ptr, 1, p->block_size); /* check that we dont get a seg fault */
-
+
int i;
for (i = 1; i < p->pool_size; i++) {
ptrs[i] = pool_get(&pool);
@@ -69,13 +69,13 @@ ParameterizedTest(struct param *p, pool, basic)
if (ptrs[i] == NULL)
break;
}
-
+
if (i < p->pool_size)
cr_assert_neq(ptrs[i], NULL);
-
+
ptr = pool_get(&pool);
cr_assert_eq(ptr, NULL);
-
+
ret = pool_destroy(&pool);
cr_assert_eq(ret, 0, "Failed to destroy pool");
diff --git a/tests/unit/queue.c b/tests/unit/queue.c
index 0fd9cc4c4..5034b9f40 100644
--- a/tests/unit/queue.c
+++ b/tests/unit/queue.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -80,25 +80,25 @@ static void * producer(void *ctx)
{
int ret;
struct param *p = ctx;
-
+
srand((unsigned) time(0) + thread_get_id());
size_t nops = rand() % 1000;
-
+
/** @todo Criterion cr_log() is broken for multi-threaded programs */
//cr_log_info("producer: tid = %lu", thread_get_id());
/* Wait for global start signal */
while (p->start == 0)
pthread_yield();
-
+
//cr_log_info("producer: wait for %zd nops", nops);
-
+
/* Wait for a random time */
for (size_t i = 0; i != nops; i += 1)
nop();
-
+
//cr_log_info("producer: start pushing");
-
+
/* Enqueue */
for (unsigned long count = 0; count < p->iter_count; count++) {
do {
@@ -106,9 +106,9 @@ static void * producer(void *ctx)
pthread_yield();
} while (ret != 1);
}
-
+
//cr_log_info("producer: finished");
-
+
return NULL;
}
@@ -116,37 +116,37 @@ static void * consumer(void *ctx)
{
int ret;
struct param *p = ctx;
-
+
srand((unsigned) time(0) + thread_get_id());
size_t nops = rand() % 1000;
-
+
//cr_log_info("consumer: tid = %lu", thread_get_id());
/* Wait for global start signal */
while (p->start == 0)
pthread_yield();
-
+
//cr_log_info("consumer: wait for %zd nops", nops);
-
+
/* Wait for a random time */
for (size_t i = 0; i != nops; i += 1)
nop();
-
+
//cr_log_info("consumer: start pulling");
-
+
/* Dequeue */
for (unsigned long count = 0; count < p->iter_count; count++) {
void *ptr;
-
+
do {
ret = queue_pull(&p->queue, &ptr);
} while (ret != 1);
-
+
//cr_log_info("consumer: %lu\n", count);
-
+
//cr_assert_eq((intptr_t) ptr, count);
}
-
+
//cr_log_info("consumer: finished");
return NULL;
@@ -169,7 +169,7 @@ void * producer_consumer(void *ctx)
for (int iter = 0; iter < p->iter_count; ++iter) {
pthread_barrier_wait(&barrier);
-
+
for (size_t i = 0; i < p->batch_size; i++) {
void *ptr = (void *) (iter * p->batch_size + i);
while (!queue_push(&p->queue, ptr))
@@ -200,13 +200,13 @@ void * producer_consumer_many(void *ctx)
/* Wait for a random time */
for (size_t i = 0; i != nops; i += 1)
nop();
-
+
void *ptrs[p->batch_size];
for (int iter = 0; iter < p->iter_count; ++iter) {
for (size_t i = 0; i < p->batch_size; i++)
ptrs[i] = (void *) (iter * p->batch_size + i);
-
+
pthread_barrier_wait(&barrier);
int pushed = 0;
@@ -235,15 +235,15 @@ Test(queue, single_threaded)
.queue_size = 1 << 10,
.start = 1 /* we start immeadiatly */
};
-
+
ret = queue_init(&p.queue, p.queue_size, &memtype_heap);
cr_assert_eq(ret, 0, "Failed to create queue");
-
+
producer(&p);
consumer(&p);
-
+
cr_assert_eq(queue_available(&q), 0);
-
+
ret = queue_destroy(&p.queue);
cr_assert_eq(ret, 0, "Failed to create queue");
}
@@ -288,25 +288,25 @@ ParameterizedTestParameters(queue, multi_threaded)
.memtype = &memtype_hugepage
}
};
-
+
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
}
ParameterizedTest(struct param *p, queue, multi_threaded, .timeout = 20)
{
int ret, cycpop;
-
+
pthread_t threads[p->thread_count];
-
+
p->start = 0;
-
+
ret = queue_init(&p->queue, p->queue_size, &memtype_heap);
cr_assert_eq(ret, 0, "Failed to create queue");
uint64_t start_tsc_time, end_tsc_time;
-
+
pthread_barrier_init(&barrier, NULL, p->thread_count);
-
+
for (int i = 0; i < p->thread_count; ++i)
pthread_create(&threads[i], NULL, p->thread_func, p);
@@ -317,12 +317,12 @@ ParameterizedTest(struct param *p, queue, multi_threaded, .timeout = 20)
for (int i = 0; i < p->thread_count; ++i)
pthread_join(threads[i], NULL);
-
+
pthread_barrier_destroy(&barrier);
end_tsc_time = rdtsc();
cycpop = (end_tsc_time - start_tsc_time) / p->iter_count;
-
+
if (cycpop < 400)
cr_log_info("cycles/op: %u\n", cycpop);
else
@@ -330,7 +330,7 @@ ParameterizedTest(struct param *p, queue, multi_threaded, .timeout = 20)
ret = queue_available(&q);
cr_assert_eq(ret, 0);
-
+
ret = queue_destroy(&p->queue);
cr_assert_eq(ret, 0, "Failed to destroy queue");
}
@@ -339,10 +339,10 @@ Test(queue, init_destroy)
{
int ret;
struct queue q = { .state = STATE_DESTROYED };
-
+
ret = queue_init(&q, 1024, &memtype_heap);
cr_assert_eq(ret, 0); /* Should succeed */
-
+
ret = queue_destroy(&q);
cr_assert_eq(ret, 0); /* Should succeed */
}
\ No newline at end of file
diff --git a/tests/unit/sample_io.c b/tests/unit/sample_io.c
index 0f26f7376..fee5a7b62 100644
--- a/tests/unit/sample_io.c
+++ b/tests/unit/sample_io.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -36,7 +36,7 @@ ParameterizedTestParameters(sample_io, read_write)
SAMPLE_IO_FORMAT_VILLAS,
SAMPLE_IO_FORMAT_JSON,
};
-
+
return cr_make_param_array(enum sample_io_format, formats, ARRAY_LEN(formats));
}
@@ -49,10 +49,10 @@ ParameterizedTest(enum sample_io_format *fmt, sample_io, read_write)
/* Prepare a sample with arbitrary data */
s = malloc(SAMPLE_LEN(16));
cr_assert_not_null(s);
-
+
t = malloc(SAMPLE_LEN(16));
cr_assert_not_null(s);
-
+
t->capacity =
s->capacity = 16;
s->length = 12;
@@ -60,14 +60,14 @@ ParameterizedTest(enum sample_io_format *fmt, sample_io, read_write)
s->format = 0;
s->ts.origin = time_now();
s->ts.received = (struct timespec) { s->ts.origin.tv_sec - 1, s->ts.origin.tv_nsec };
-
+
for (int i = 0; i < s->length; i++)
s->data[i].f = i * 1.2;
/* Open a file for IO */
f = tmpfile();
cr_assert_not_null(f);
-
+
ret = sample_io_fprint(f, s, *fmt, SAMPLE_IO_ALL);
cr_assert_eq(ret, 0);
@@ -79,15 +79,15 @@ ParameterizedTest(enum sample_io_format *fmt, sample_io, read_write)
cr_assert_eq(s->length, t->length);
cr_assert_eq(s->sequence, t->sequence);
cr_assert_eq(s->format, t->format);
-
+
cr_assert_eq(s->ts.origin.tv_sec, t->ts.origin.tv_sec);
cr_assert_eq(s->ts.origin.tv_nsec, t->ts.origin.tv_nsec);
cr_assert_eq(s->ts.received.tv_sec, t->ts.received.tv_sec);
cr_assert_eq(s->ts.received.tv_nsec, t->ts.received.tv_nsec);
-
+
for (int i = 0; i < MIN(s->length, t->length); i++)
cr_assert_float_eq(s->data[i].f, t->data[i].f, 1e-6);
-
+
fclose(f);
free(s);
diff --git a/tests/unit/timing.c b/tests/unit/timing.c
index 3d5fac3d6..1083ad3e4 100644
--- a/tests/unit/timing.c
+++ b/tests/unit/timing.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -30,9 +30,9 @@ Test(timing, time_now)
{
struct timespec now1 = time_now();
struct timespec now2 = time_now();
-
+
double delta = time_delta(&now1, &now2);
-
+
cr_assert_float_eq(delta, 0, 1e-5, "time_now() shows large variance!");
cr_assert_gt(delta, 0, "time_now() was reordered!");
}
@@ -41,9 +41,9 @@ Test(timing, time_diff)
{
struct timespec ts1 = { .tv_sec = 0, .tv_nsec = 1}; /* Value doesnt matter */
struct timespec ts2 = { .tv_sec = 1, .tv_nsec = 0}; /* Overflow in nano seconds! */
-
+
struct timespec ts3 = time_diff(&ts1, &ts2);
-
+
/* ts4 == ts2? */
cr_assert_eq(ts3.tv_sec, 0);
cr_assert_eq(ts3.tv_nsec, 999999999);
@@ -53,9 +53,9 @@ Test(timing, time_add)
{
struct timespec ts1 = { .tv_sec = 1, .tv_nsec = 999999999}; /* Value doesnt matter */
struct timespec ts2 = { .tv_sec = 1, .tv_nsec = 1}; /* Overflow in nano seconds! */
-
+
struct timespec ts3 = time_add(&ts1, &ts2);
-
+
/* ts4 == ts2? */
cr_assert_eq(ts3.tv_sec, 3);
cr_assert_eq(ts3.tv_nsec, 0);
@@ -65,16 +65,16 @@ Test(timing, time_delta)
{
struct timespec ts1 = { .tv_sec = 1, .tv_nsec = 123}; /* Value doesnt matter */
struct timespec ts2 = { .tv_sec = 5, .tv_nsec = 246}; /* Overflow in nano seconds! */
-
+
double delta = time_delta(&ts1, &ts2);
-
+
cr_assert_float_eq(delta, 4 + 123e-9, 1e-9);
}
Test(timing, time_from_double)
{
double ref = 1234.56789;
-
+
struct timespec ts = time_from_double(ref);
cr_assert_eq(ts.tv_sec, 1234);
@@ -84,63 +84,63 @@ Test(timing, time_from_double)
Test(timing, time_to_from_double)
{
double ref = 1234.56789;
-
+
struct timespec ts = time_from_double(ref);
double dbl = time_to_double(&ts);
-
- cr_assert_float_eq(dbl, ref, 1e-9);
+
+ cr_assert_float_eq(dbl, ref, 1e-9);
}
Test(timing, timerfd_create_rate, .timeout = 20)
{
struct timespec start, end;
-
+
double rate = 5, waited;
-
+
int tfd = timerfd_create_rate(rate);
-
+
cr_assert(tfd > 0);
-
+
timerfd_wait(tfd);
-
+
int i;
for (i = 0; i < 10; i++) {
start = time_now();
timerfd_wait(tfd);
-
+
end = time_now();
waited = time_delta(&start, &end);
-
+
if (fabs(waited - 1.0 / rate) > 10e-3)
break;
}
-
+
if (i < 10)
cr_assert_float_eq(waited, 1.0 / rate, 10e-3, "We slept for %f instead of %f secs in round %d", waited, 1.0 / rate, i);
-
+
close(tfd);
}
Test(timing, timerfd_wait_until, .timeout = 10)
{
int tfd = timerfd_create(CLOCK_REALTIME, 0);
-
+
cr_assert(tfd > 0);
-
+
double waitfor = 2.423456789;
-
+
struct timespec start = time_now();
struct timespec diff = time_from_double(waitfor);
struct timespec future = time_add(&start, &diff);
-
+
timerfd_wait_until(tfd, &future);
-
+
struct timespec end = time_now();
-
+
double waited = time_delta(&start, &end);
-
+
cr_assert_float_eq(waited, waitfor, 1e-2, "We slept for %f instead of %f secs", waited, waitfor);
-
+
close(tfd);
}
\ No newline at end of file
diff --git a/tests/unit/utils.c b/tests/unit/utils.c
index 45d484124..5684934a3 100644
--- a/tests/unit/utils.c
+++ b/tests/unit/utils.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -34,7 +34,7 @@ Test(utils, box_muller)
for (int i = 0; i < iter; i++) {
n = box_muller(0, 1);
-
+
if (n > 2 || n < -2) sigma[2]++;
else if (n > 1 || n < -1) sigma[1]++;
else sigma[0]++;
@@ -64,18 +64,18 @@ Test(utils, cpuset)
cpu_set_t cset2;
uintmax_t int1 = 0x1234567890ABCDEFULL;
uintmax_t int2 = 0;
-
+
cpuset_from_integer(int1, &cset1);
-
+
cpulist_create(str, sizeof(str), &cset1);
-
+
ret = cpulist_parse(str, &cset2, 1);
cr_assert_eq(ret, 0);
-
+
cr_assert(CPU_EQUAL(&cset1, &cset2));
-
+
cpuset_to_integer(&cset2, &int2);
-
+
cr_assert_eq(int1, int2);
}
@@ -83,14 +83,14 @@ Test(utils, memdup)
{
char orig[1024], *copy;
size_t len;
-
+
len = read_random(orig, sizeof(orig));
cr_assert_eq(len, sizeof(orig));
-
+
copy = memdup(orig, sizeof(orig));
cr_assert_not_null(copy);
cr_assert_arr_eq(copy, orig, sizeof(orig));
-
+
free(copy);
}
@@ -99,7 +99,7 @@ Test(utils, is_aligned)
/* Positive */
cr_assert(IS_ALIGNED(1, 1));
cr_assert(IS_ALIGNED(128, 64));
-
+
/* Negative */
cr_assert(!IS_ALIGNED(55, 16));
cr_assert(!IS_ALIGNED(55, 55));
@@ -119,7 +119,7 @@ Test(utils, is_pow2)
cr_assert(IS_POW2(1));
cr_assert(IS_POW2(2));
cr_assert(IS_POW2(64));
-
+
/* Negative */
cr_assert(!IS_POW2(0));
cr_assert(!IS_POW2(3));
@@ -140,7 +140,7 @@ Test(utils, version)
version_parse("1.3", &v2);
version_parse("55", &v3);
version_parse("66", &v4);
-
+
cr_assert_lt(version_cmp(&v1, &v2), 0);
cr_assert_eq(version_cmp(&v1, &v1), 0);
cr_assert_gt(version_cmp(&v2, &v1), 0);
@@ -151,14 +151,14 @@ Test(utils, sha1sum)
{
int ret;
FILE *f = tmpfile();
-
+
unsigned char hash[SHA_DIGEST_LENGTH];
unsigned char expected[SHA_DIGEST_LENGTH] = { 0x69, 0xdf, 0x29, 0xdf, 0x1f, 0xf2, 0xd2, 0x5d, 0xb8, 0x68, 0x6c, 0x02, 0x8d, 0xdf, 0x40, 0xaf, 0xb3, 0xc1, 0xc9, 0x4d };
-
+
/* Write the first 512 fibonaccia numbers to the file */
for (int i = 0, a = 0, b = 1, c; i < 512; i++, a = b, b = c) {
c = a + b;
-
+
fwrite((void *) &c, sizeof(c), 1, f);
}
diff --git a/tools/conf2json.c b/tools/conf2json.c
index 61c13cd67..20d37aec3 100644
--- a/tools/conf2json.c
+++ b/tools/conf2json.c
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -39,30 +39,30 @@ int main(int argc, char *argv[])
config_t cfg;
config_setting_t *cfg_root;
json_t *json;
-
+
if (argc != 1) {
usage();
exit(EXIT_FAILURE);
}
-
+
config_init(&cfg);
-
+
ret = config_read(&cfg, stdin);
if (ret != CONFIG_TRUE)
return ret;
-
+
cfg_root = config_root_setting(&cfg);
-
+
json = config_to_json(cfg_root);
if (!json)
return -1;
-
+
ret = json_dumpf(json, stdout, JSON_INDENT(2)); fflush(stdout);
if (ret)
return ret;
-
+
json_decref(json);
config_destroy(&cfg);
-
+
return 0;
}
diff --git a/tools/fiware/fiware-query.sh b/tools/fiware/fiware-query.sh
index 37aac7f11..4f1dda860 100755
--- a/tools/fiware/fiware-query.sh
+++ b/tools/fiware/fiware-query.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/fiware/fiware-update.sh b/tools/fiware/fiware-update.sh
index 9a9d8e7fe..e9a4b7e8c 100755
--- a/tools/fiware/fiware-update.sh
+++ b/tools/fiware/fiware-update.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
@@ -46,5 +46,5 @@
}
],
"updateAction": "UPDATE"
-}
+}
EOF
\ No newline at end of file
diff --git a/tools/fix_git_history.sh b/tools/fix_git_history.sh
index ea94c0690..cff1169b0 100755
--- a/tools/fix_git_history.sh
+++ b/tools/fix_git_history.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-#
+#
# Rewrite Git history
#
# @author Steffen Vogel
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
###################################################################################
diff --git a/tools/rebind_device.sh b/tools/rebind_device.sh
index edfa9a026..67fb75bbe 100755
--- a/tools/rebind_device.sh
+++ b/tools/rebind_device.sh
@@ -1,47 +1,47 @@
-#!/bin/bash
-#
-# Detach and rebind a PCI device to a PCI kernel driver
-#
-# @author Steffen Vogel
-# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
-# @license GNU General Public License (version 3)
-#
-# VILLASnode
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-##################################################################################
-
-if [ "$#" -ne 2 ]; then
- echo "usage: $0 BUS:DEV:FNC DRIVER"
- exit 1
-fi
-
-BDF=$1
-DRIVER=$2
-
-VENDOR=$(cut -b3- /sys/bus/pci/devices/${BDF}/vendor)
-DEVICE=$(cut -b3- /sys/bus/pci/devices/${BDF}/device)
-
-SYSFS_DEVICE=/sys/bus/pci/devices/${BDF}
-SYSFS_DRIVER=/sys/bus/pci/drivers/${DRIVER}
-
-echo "Device: $VENDOR $DEVICE $BDF"
-
-if [ -L "${SYSFS_DEVICE}/driver" ] && [ -d "${SYSFS_DEVICE}/driver" ]; then
- echo ${BDF} > ${SYSFS_DEVICE}/driver/unbind
-fi
-
-echo "${VENDOR} ${DEVICE}" > ${SYSFS_DRIVER}/new_id
-echo "${BDF}" > ${SYSFS_DRIVER}/bind
-echo "${VENDOR} ${DEVICE}" > ${SYSFS_DRIVER}/remove_id
+#!/bin/bash
+#
+# Detach and rebind a PCI device to a PCI kernel driver
+#
+# @author Steffen Vogel
+# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
+# @license GNU General Public License (version 3)
+#
+# VILLASnode
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+##################################################################################
+
+if [ "$#" -ne 2 ]; then
+ echo "usage: $0 BUS:DEV:FNC DRIVER"
+ exit 1
+fi
+
+BDF=$1
+DRIVER=$2
+
+VENDOR=$(cut -b3- /sys/bus/pci/devices/${BDF}/vendor)
+DEVICE=$(cut -b3- /sys/bus/pci/devices/${BDF}/device)
+
+SYSFS_DEVICE=/sys/bus/pci/devices/${BDF}
+SYSFS_DRIVER=/sys/bus/pci/drivers/${DRIVER}
+
+echo "Device: $VENDOR $DEVICE $BDF"
+
+if [ -L "${SYSFS_DEVICE}/driver" ] && [ -d "${SYSFS_DEVICE}/driver" ]; then
+ echo ${BDF} > ${SYSFS_DEVICE}/driver/unbind
+fi
+
+echo "${VENDOR} ${DEVICE}" > ${SYSFS_DRIVER}/new_id
+echo "${BDF}" > ${SYSFS_DRIVER}/bind
+echo "${VENDOR} ${DEVICE}" > ${SYSFS_DRIVER}/remove_id
diff --git a/tools/remove_lgpl.sh b/tools/remove_lgpl.sh
index c36a799eb..7c71eb063 100755
--- a/tools/remove_lgpl.sh
+++ b/tools/remove_lgpl.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
###################################################################################
diff --git a/tools/report_metric.sh b/tools/report_metric.sh
index e257226cb..80e6c38fd 100755
--- a/tools/report_metric.sh
+++ b/tools/report_metric.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/reset_pci_device.sh b/tools/reset_pci_device.sh
index 9c2c8e458..ae3b14486 100755
--- a/tools/reset_pci_device.sh
+++ b/tools/reset_pci_device.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/tc/tc-dump.sh b/tools/tc/tc-dump.sh
index cac81fa6e..85450f0ed 100755
--- a/tools/tc/tc-dump.sh
+++ b/tools/tc/tc-dump.sh
@@ -12,12 +12,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/tc/tc-netem.sh b/tools/tc/tc-netem.sh
index 30b59c69f..e84addb32 100755
--- a/tools/tc/tc-netem.sh
+++ b/tools/tc/tc-netem.sh
@@ -14,12 +14,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/tc/tc-netem2.sh b/tools/tc/tc-netem2.sh
index 06b48760d..f6c5144b3 100755
--- a/tools/tc/tc-netem2.sh
+++ b/tools/tc/tc-netem2.sh
@@ -14,12 +14,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
##################################################################################
diff --git a/tools/villas.sh b/tools/villas.sh
index a7c3f9e70..c31a8e4cd 100755
--- a/tools/villas.sh
+++ b/tools/villas.sh
@@ -17,12 +17,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
###################################################################################
@@ -42,7 +42,7 @@ ARGS=${@:2}
if ! [[ "$TOOL" =~ $(echo ^\($TOOLS\)$) ]]; then
echo "Usage: villas [TOOL]" 1>&2
echo " TOOL is one of ${TOOLS}"
- echo
+ echo
echo "For detailed documentation, please run 'villas node'"
echo " and point your web browser to http://localhost:80"
echo
diff --git a/web/socket/api.js b/web/socket/api.js
index 66c1efc27..f3433e9d3 100644
--- a/web/socket/api.js
+++ b/web/socket/api.js
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -24,7 +24,7 @@ function Api(v, connected, error)
{
this.version = v
this.ids = new Object();
-
+
var url = wsUrl('v1');
var self = this;
@@ -43,13 +43,13 @@ function Api(v, connected, error)
this.connection.onmessage = function(e) {
var resp = JSON.parse(e.data);
var handler;
-
+
console.log('API response received', resp);
-
+
handler = self.ids[resp.id];
if (handler !== undefined) {
handler(resp.response);
-
+
delete self.ids[resp.id];
}
};
@@ -62,9 +62,9 @@ Api.prototype.request = function(action, request, handler)
request: request,
id : guid()
};
-
+
this.ids[req.id] = handler;
-
+
console.log('API request sent', req);
this.connection.send(JSON.stringify(req))
diff --git a/web/socket/app.js b/web/socket/app.js
index 2157fd889..220bc6809 100644
--- a/web/socket/app.js
+++ b/web/socket/app.js
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -50,17 +50,17 @@ var xFuture = xDelta * 0.1;
$(document).ready(function() {
api = new Api('v1', apiConnected);
-
+
$('#play').click(function(e, ui) {
connection = wsConnect(currentNode);
paused = false;
});
-
+
$('#pause').click(function(e, ui) {
connection.close();
paused = true;
});
-
+
$('#timespan').slider({
min : 1000,
max : 10000,
@@ -69,7 +69,7 @@ $(document).ready(function() {
updatePlotWindow(ui.value);
}
});
-
+
$('#updaterate').slider({
min : 1,
max : 50,
@@ -86,12 +86,12 @@ $(document).ready(function() {
max : 100,
slide : sendData
});
-
+
$('.inputs-checkboxes input').checkboxradio()
.each(function(idx, elm) {
$(elm).change(sendData);
});
-
+
timer = setInterval(updatePlot, 1000.0 / updateRate);
});
@@ -127,7 +127,7 @@ function apiConnected()
api.request('nodes', {},
function(response) {
nodes = response;
-
+
console.log("Found " + nodes.length + " nodes:", nodes);
for (var i = 0; i < nodes.length; i++)
@@ -163,7 +163,7 @@ function updateNodeList()
);
}
});
-
+
$('.node-selector').buttonset();
}
@@ -177,14 +177,14 @@ function updatePlotWindow(delta)
function updatePlot()
{
var data = [];
-
+
if (!redrawPlot)
return;
// add data to arrays
for (var i = 0; i < plotData.length; i++) {
var seriesOptions = nodes
-
+
data[i] = {
data : plotData[i],
shadowSize : 0,
@@ -193,11 +193,11 @@ function updatePlot()
lineWidth: 2
}
}
-
+
if (currentNode.series !== undefined && currentNode.series[i] !== undefined)
$.extend(true, data[i], currentNode.series[i]);
}
-
+
var options = {
xaxis: {
min: Date.now() - xPast,
@@ -212,7 +212,7 @@ function updatePlot()
/* update plot */
$.plot('.plot-container div', data, $.extend(true, options, plotOptions));
-
+
redrawPlot = false;
}
@@ -222,18 +222,18 @@ function wsConnect(node)
var conn = new WebSocket(url, 'live');
conn.binaryType = 'arraybuffer';
-
+
conn.onopen = function() {
$('#status')
.text('Connected')
.css('color', 'green');
-
+
console.log('WebSocket connection established');
};
conn.onclose = function(error) {
console.log('WebSocket connection closed', error);
-
+
$('#status')
.text('Disconnected' + (error.reason != '' ? ' (' + error.reason + ')' : ''))
.css('color', 'red');
@@ -248,13 +248,13 @@ function wsConnect(node)
conn.onerror = function(error) {
console.log('WebSocket connection error', error);
-
+
$('#status').text('Status: Error: ' + error.message);
};
conn.onmessage = function(e) {
var msgs = Msg.fromArrayBufferVector(e.data);
-
+
console.log('Received ' + msgs.length + ' messages with ' + msgs[0].data.length + ' values from id ' + msgs[0].id + ' with timestamp ' + msgs[0].timestamp);
for (var j = 0; j < plotData.length; j++) {
@@ -265,7 +265,7 @@ function wsConnect(node)
for (var j = 0; j < msgs.length; j++) {
var msg = msgs[j];
-
+
if (msg.id != currentNode.id)
continue;
@@ -277,10 +277,10 @@ function wsConnect(node)
for (var i = 0; i < msg.length; i++)
plotData[i].push([msg.timestamp, msg.data[i]]);
}
-
+
redrawPlot = true;
};
-
+
return conn;
};
@@ -294,14 +294,14 @@ function wsUrl(endpoint)
url += 'wss://';
else
url += 'ws://';
-
+
url += l.hostname;
-
+
if ((l.port) && (l.port != 80) && (l.port != 443))
url += ':'+ l.port;
url += '/' + endpoint;
-
+
return url;
}
diff --git a/web/socket/file.js b/web/socket/file.js
index 5cb79f0c5..f474c1cae 100644
--- a/web/socket/file.js
+++ b/web/socket/file.js
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -24,7 +24,7 @@ function fileStart(e)
{
var file = e.target.files[0];
var reader = new FileReader();
-
+
var start;
var msgs = [ ]
var position = 0;
@@ -43,14 +43,14 @@ function fileStart(e)
if (msgs.length > 0) {
var offset = Date.now() - msgs[0].ts;
var data = [];
-
+
for (var i = 0; i < msgs.length; i++)
data.push(msgs[i].ts + offset, msgs[i].data[0]);
-
+
plotData.push(data);
}
else {
-
+
}
};
diff --git a/web/socket/msg.js b/web/socket/msg.js
index a5c164ad4..8de38b4df 100644
--- a/web/socket/msg.js
+++ b/web/socket/msg.js
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -39,7 +39,7 @@ function Msg(c)
this.type = typeof c.type === 'undefined' ? Msg.prototype.TYPE_DATA : c.type;
this.id = typeof c.id === 'undefined' ? -1 : c.id;
this.timestamp = typeof c.timestamp === 'undefined' ? Date.now() : c.timestamp;
-
+
if (Array.isArray(c.data)) {
this.length = c.data.length;
this.data = c.data;
@@ -73,7 +73,7 @@ Msg.fromArrayBuffer = function(data)
timestamp: data.getUint32(0x08, 1) * 1e3 +
data.getUint32(0x0C, 1) * 1e-6,
});
-
+
msg.blob = new DataView( data.buffer, data.byteOffset + 0x00, Msg.bytes(msg.length));
msg.data = new Float32Array(data.buffer, data.byteOffset + 0x10, msg.length);
@@ -89,7 +89,7 @@ Msg.fromArrayBufferVector = function(blob)
/* for every msg in vector */
while (offset < blob.byteLength) {
var msg = Msg.fromArrayBuffer(new DataView(blob, offset));
-
+
if (msg != undefined) {
msgs.push(msg);
@@ -104,21 +104,21 @@ Msg.prototype.toArrayBuffer = function()
{
buffer = new ArrayBuffer(Msg.bytes(this.length))
view = new DataView(buffer);
-
+
var bits = 0;
bits |= (this.version & 0xF) << Msg.prototype.OFFSET_VERSION;
bits |= (this.type & 0x3) << Msg.prototype.OFFSET_TYPE;
-
+
var sec = Math.floor(this.timestamp / 1e3);
var nsec = (this.timestamp - sec * 1e3) * 1e6;
-
+
view.setUint8( 0x00, bits, true);
view.setUint8( 0x01, this.id, true);
view.setUint16(0x02, this.length, true);
view.setUint32(0x04, this.sequence, true);
view.setUint32(0x08, sec, true);
view.setUint32(0x0C, nsec, true);
-
+
data = new Float32Array(buffer, 0x10, this.length);
data.set(this.data);
diff --git a/web/socket/utils.js b/web/socket/utils.js
index ef3b1a337..486876c42 100644
--- a/web/socket/utils.js
+++ b/web/socket/utils.js
@@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/