-
Notifications
You must be signed in to change notification settings - Fork 8
/
fndb.lisp
175 lines (139 loc) · 5.09 KB
/
fndb.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
;;;; By Nikodemus Siivola <[email protected]>, 2009.
;;;;
;;;; Permission is hereby granted, free of charge, to any person
;;;; obtaining a copy of this software and associated documentation files
;;;; (the "Software"), to deal in the Software without restriction,
;;;; including without limitation the rights to use, copy, modify, merge,
;;;; publish, distribute, sublicense, and/or sell copies of the Software,
;;;; and to permit persons to whom the Software is furnished to do so,
;;;; subject to the following conditions:
;;;;
;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;;;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
;;;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
;;;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(in-package :sb-cga)
;;;; KLUDGE: DEFKNOWN macro for use in this file -- reader conditionals
;;;; allowed here. Easier then adding multiple port-files, I think.
;;;;
;;;; Non-SBCL/CMUCL implementations should expand into an FTYPE proclamation
;;;; unless the implementation has something closer to CMU-style defknown.
(eval-when (:compile-toplevel)
#+sbcl
(defmacro defknown (name arg-types ret-type attributes &rest keys)
`(sb-c:defknown ,name ,arg-types ,ret-type
,(mapcar (lambda (attr)
(intern (symbol-name attr) :sb-c))
attributes)
,@keys))
#-sbcl
(defmacro defknown (name arg-types ret-type attributes &rest keys)
`(declaim (ftype (function ,arg-types ,ret-type) ,name))))
;;;; VOPs for operations on VECs
;;;;
;;;; %FOO always has the result as the first argument, but the result
;;;; argument itself is not an operand.
;;;;
;;;; %FOO/1 is the same operation as %FOO, but with one less argument: the
;;;; _first_ argument both receives the result, and is used as an operand.
;;;;
;;;; %FOO/2 is the same operation as %FOO, but with one less argument: the
;;;; _second_ argument both receives the result, and is used as an operand.
;;;;
;;;; Not everything has a %FOO/1 or %FOO/2 version.
;;;;
;;;;
(defknown %vec= (vec vec) boolean
(any #+sb-cga-sse2 always-translatable))
(defknown %copy-vec (vec vec) vec
(any)
:result-arg 0)
(defknown %vec+ (vec vec vec) vec
(any)
:result-arg 0)
(defknown %%vec+/1 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%vec+/2 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 1)
(defknown %vec- (vec vec vec) vec
(any)
:result-arg 0)
(defknown %%vec-/1 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%vec-/2 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 1)
(defknown %vec* (vec vec single-float) vec
(any)
:result-arg 0)
(defknown %%vec*/1 (vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %vec/ (vec vec single-float) vec
(any)
:result-arg 0)
(defknown %%vec//1 (vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %dot-product (vec vec) single-float
(any #+sb-cga-sse2 always-translatable))
(defknown %cross-product (vec vec vec) vec
(any)
:result-arg 0)
(defknown %normalized-cross-product (vec vec vec) vec
(any)
:result-arg 0)
(defknown %hadamard-product (vec vec vec) vec (any)
:result-arg 0)
(defknown %%hadamard-product/1 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%hadamard-product/2 (vec vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 1)
(defknown %vec-length (vec) single-float
(any #+sb-cga-sse2 always-translatable))
(defknown %normalize (vec vec) vec (any)
:result-arg 0)
(defknown %%normalize/1 (vec) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%normalized-vec (vec single-float single-float single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %vec-lerp (vec vec vec single-float) vec
(any)
:result-arg 0)
(defknown %%vec-lerp/1 (vec vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%vec-lerp/2 (vec vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 1)
(defknown %transform-point (vec vec matrix) vec
(any)
:result-arg 0)
(defknown %%transform-point/1 (vec matrix) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %transform-direction (vec vec matrix) vec
(any)
:result-arg 0)
(defknown %%transform-direction/1 (vec matrix) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %adjust-vec (vec vec vec single-float) vec
(any)
:result-arg 0)
(defknown %%adjust-vec/1 (vec vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 0)
(defknown %%adjust-vec/2 (vec vec single-float) vec
(any #+sb-cga-sse2 always-translatable)
:result-arg 1)