Skip to content

Commit d750c93

Browse files
committed
Refactor to use N-API
1 parent affa0cb commit d750c93

File tree

19 files changed

+356
-562
lines changed

19 files changed

+356
-562
lines changed

lib/node_modules/@stdlib/math/base/special/pdiff/benchmark/benchmark.wasm.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

lib/node_modules/@stdlib/math/base/special/pdiff/benchmark/c/Makefile

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2018 The Stdlib Authors.
4+
# Copyright (c) 2020 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -16,14 +16,15 @@
1616
# limitations under the License.
1717
#/
1818

19-
2019
# VARIABLES #
2120

2221
ifndef VERBOSE
2322
QUIET := @
23+
else
24+
QUIET :=
2425
endif
2526

26-
# Determine the OS:
27+
# Determine the OS ([1][1], [2][2]).
2728
#
2829
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
2930
# [2]: http://stackoverflow.com/a/27776822/2225624
@@ -36,6 +37,10 @@ ifneq (, $(findstring MSYS,$(OS)))
3637
else
3738
ifneq (, $(findstring CYGWIN,$(OS)))
3839
OS := WINNT
40+
else
41+
ifneq (, $(findstring Windows_NT,$(OS)))
42+
OS := WINNT
43+
endif
3944
endif
4045
endif
4146
endif
@@ -54,7 +59,7 @@ CFLAGS ?= \
5459
-Wall \
5560
-pedantic
5661

57-
# Determine whether to generate [position independent code][1]:
62+
# Determine whether to generate position independent code ([1][1], [2][2]).
5863
#
5964
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
6065
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
@@ -68,39 +73,53 @@ endif
6873
c_targets := benchmark.out
6974

7075

71-
# TARGETS #
76+
# RULES #
7277

73-
# Default target.
78+
#/
79+
# Compiles C source files.
7480
#
75-
# This target is the default target.
76-
81+
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
82+
# @param {string} [CFLAGS] - C compiler options
83+
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`)
84+
#
85+
# @example
86+
# make
87+
#
88+
# @example
89+
# make all
90+
#/
7791
all: $(c_targets)
7892

7993
.PHONY: all
8094

81-
82-
# Compile C source.
95+
#/
96+
# Compiles C source files.
8397
#
84-
# This target compiles C source files.
85-
98+
# @private
99+
# @param {string} CC - C compiler
100+
# @param {string} CFLAGS - C compiler flags
101+
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
102+
#/
86103
$(c_targets): %.out: %.c
87104
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm
88105

89-
90-
# Run a benchmark.
106+
#/
107+
# Runs compiled benchmarks.
91108
#
92-
# This target runs a benchmark.
93-
109+
# @example
110+
# make run
111+
#/
94112
run: $(c_targets)
95113
$(QUIET) ./$<
96114

97115
.PHONY: run
98116

99-
100-
# Perform clean-up.
117+
#/
118+
# Removes generated files.
101119
#
102-
# This target removes generated files.
103-
120+
# @example
121+
# make clean
122+
#/
104123
clean:
105124
$(QUIET) -rm -f *.o *.out
106125

lib/node_modules/@stdlib/math/base/special/pdiff/benchmark/c/benchmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ double rand_double() {
9595
*/
9696
double pdiff( double x, double y ) {
9797
if ( x != x || y != y ) {
98-
return NAN;
98+
return 0.0 / 0.0;
9999
}
100100
if ( x > y ) {
101101
return x - y;
@@ -110,10 +110,10 @@ double pdiff( double x, double y ) {
110110
*/
111111
double benchmark() {
112112
double elapsed;
113+
double t;
113114
double x;
114115
double y;
115116
double z;
116-
double t;
117117
int i;
118118

119119
t = tic();

lib/node_modules/@stdlib/math/base/special/pdiff/benchmark/c/native/Makefile

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2018 The Stdlib Authors.
4+
# Copyright (c) 2020 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -16,14 +16,15 @@
1616
# limitations under the License.
1717
#/
1818

19-
2019
# VARIABLES #
2120

2221
ifndef VERBOSE
2322
QUIET := @
23+
else
24+
QUIET :=
2425
endif
2526

26-
# Determine the OS:
27+
# Determine the OS ([1][1], [2][2]).
2728
#
2829
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
2930
# [2]: http://stackoverflow.com/a/27776822/2225624
@@ -36,6 +37,10 @@ ifneq (, $(findstring MSYS,$(OS)))
3637
else
3738
ifneq (, $(findstring CYGWIN,$(OS)))
3839
OS := WINNT
40+
else
41+
ifneq (, $(findstring Windows_NT,$(OS)))
42+
OS := WINNT
43+
endif
3944
endif
4045
endif
4146
endif
@@ -54,7 +59,7 @@ CFLAGS ?= \
5459
-Wall \
5560
-pedantic
5661

57-
# Determine whether to generate [position independent code][1]:
62+
# Determine whether to generate position independent code ([1][1], [2][2]).
5863
#
5964
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
6065
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
@@ -80,39 +85,61 @@ LIBPATH ?=
8085
c_targets := benchmark.out
8186

8287

83-
# TARGETS #
88+
# RULES #
8489

85-
# Default target.
90+
#/
91+
# Compiles source files.
8692
#
87-
# This target is the default target.
88-
93+
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
94+
# @param {string} [CFLAGS] - C compiler options
95+
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
96+
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
97+
# @param {string} [SOURCE_FILES] - list of source files
98+
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
99+
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
100+
#
101+
# @example
102+
# make
103+
#
104+
# @example
105+
# make all
106+
#/
89107
all: $(c_targets)
90108

91109
.PHONY: all
92110

93-
94-
# Compile C source.
111+
#/
112+
# Compiles C source files.
95113
#
96-
# This target compiles C source files.
97-
114+
# @private
115+
# @param {string} CC - C compiler (e.g., `gcc`)
116+
# @param {string} CFLAGS - C compiler options
117+
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
118+
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
119+
# @param {string} SOURCE_FILES - list of source files
120+
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
121+
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
122+
#/
98123
$(c_targets): %.out: %.c
99124
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
100125

101-
102-
# Run a benchmark.
126+
#/
127+
# Runs compiled benchmarks.
103128
#
104-
# This target runs a benchmark.
105-
129+
# @example
130+
# make run
131+
#/
106132
run: $(c_targets)
107133
$(QUIET) ./$<
108134

109135
.PHONY: run
110136

111-
112-
# Perform clean-up.
137+
#/
138+
# Removes generated files.
113139
#
114-
# This target removes generated files.
115-
140+
# @example
141+
# make clean
142+
#/
116143
clean:
117144
$(QUIET) -rm -f *.o *.out
118145

lib/node_modules/@stdlib/math/base/special/pdiff/benchmark/c/native/benchmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
/**
2020
* Benchmark `pdiff`.
2121
*/
22+
#include "stdlib/math/base/special/pdiff.h"
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425
#include <math.h>
2526
#include <time.h>
2627
#include <sys/time.h>
27-
#include "stdlib_base_pdiff.h"
2828

2929
#define NAME "pdiff"
3030
#define ITERATIONS 1000000
@@ -94,10 +94,10 @@ double rand_double() {
9494
*/
9595
double benchmark() {
9696
double elapsed;
97+
double t;
9798
double x;
9899
double y;
99100
double z;
100-
double t;
101101
int i;
102102

103103
t = tic();

lib/node_modules/@stdlib/math/base/special/pdiff/binding.gyp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858

5959
# Define directories which contain relevant include headers:
6060
'include_dirs': [
61-
# NAN absolute file path:
62-
'<!(node -e "require(\'nan\')")',
63-
6461
# Local include directory:
6562
'<@(include_dirs)',
6663
],

0 commit comments

Comments
 (0)