~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to packages/extra/univint/FixMath.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
     File:       FixMath.p
 
3
 
 
4
     Contains:   Fixed Math Interfaces.
 
5
 
 
6
     Version:    Technology: Mac OS 8
 
7
                 Release:    Universal Interfaces 3.4.2
 
8
 
 
9
     Copyright:  � 1985-2002 by Apple Computer, Inc., all rights reserved
 
10
 
 
11
     Bugs?:      For bug reports, consult the following page on
 
12
                 the World Wide Web:
 
13
 
 
14
                     http://www.freepascal.org/bugs.html
 
15
 
 
16
}
 
17
 
 
18
 
 
19
{
 
20
    Modified for use with Free Pascal
 
21
    Version 200
 
22
    Please report any bugs to <gpc@microbizz.nl>
 
23
}
 
24
 
 
25
{$mode macpas}
 
26
{$packenum 1}
 
27
{$macro on}
 
28
{$inline on}
 
29
{$CALLING MWPASCAL}
 
30
 
 
31
unit FixMath;
 
32
interface
 
33
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
 
34
{$setc GAP_INTERFACES_VERSION := $0200}
 
35
 
 
36
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 
37
    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 
38
{$endc}
 
39
 
 
40
{$ifc defined CPUPOWERPC and defined CPUI386}
 
41
        {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 
42
{$endc}
 
43
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 
44
        {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 
45
{$endc}
 
46
 
 
47
{$ifc not defined __ppc__ and defined CPUPOWERPC}
 
48
        {$setc __ppc__ := 1}
 
49
{$elsec}
 
50
        {$setc __ppc__ := 0}
 
51
{$endc}
 
52
{$ifc not defined __i386__ and defined CPUI386}
 
53
        {$setc __i386__ := 1}
 
54
{$elsec}
 
55
        {$setc __i386__ := 0}
 
56
{$endc}
 
57
 
 
58
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 
59
        {$error Conflicting definitions for __ppc__ and __i386__}
 
60
{$endc}
 
61
 
 
62
{$ifc defined __ppc__ and __ppc__}
 
63
        {$setc TARGET_CPU_PPC := TRUE}
 
64
        {$setc TARGET_CPU_X86 := FALSE}
 
65
{$elifc defined __i386__ and __i386__}
 
66
        {$setc TARGET_CPU_PPC := FALSE}
 
67
        {$setc TARGET_CPU_X86 := TRUE}
 
68
{$elsec}
 
69
        {$error Neither __ppc__ nor __i386__ is defined.}
 
70
{$endc}
 
71
{$setc TARGET_CPU_PPC_64 := FALSE}
 
72
 
 
73
{$ifc defined FPC_BIG_ENDIAN}
 
74
        {$setc TARGET_RT_BIG_ENDIAN := TRUE}
 
75
        {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
 
76
{$elifc defined FPC_LITTLE_ENDIAN}
 
77
        {$setc TARGET_RT_BIG_ENDIAN := FALSE}
 
78
        {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
 
79
{$elsec}
 
80
        {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
 
81
{$endc}
 
82
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
 
83
{$setc CALL_NOT_IN_CARBON := FALSE}
 
84
{$setc OLDROUTINENAMES := FALSE}
 
85
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
 
86
{$setc OPAQUE_UPP_TYPES := TRUE}
 
87
{$setc OTCARBONAPPLICATION := TRUE}
 
88
{$setc OTKERNEL := FALSE}
 
89
{$setc PM_USE_SESSION_APIS := TRUE}
 
90
{$setc TARGET_API_MAC_CARBON := TRUE}
 
91
{$setc TARGET_API_MAC_OS8 := FALSE}
 
92
{$setc TARGET_API_MAC_OSX := TRUE}
 
93
{$setc TARGET_CARBON := TRUE}
 
94
{$setc TARGET_CPU_68K := FALSE}
 
95
{$setc TARGET_CPU_MIPS := FALSE}
 
96
{$setc TARGET_CPU_SPARC := FALSE}
 
97
{$setc TARGET_OS_MAC := TRUE}
 
98
{$setc TARGET_OS_UNIX := FALSE}
 
99
{$setc TARGET_OS_WIN32 := FALSE}
 
100
{$setc TARGET_RT_MAC_68881 := FALSE}
 
101
{$setc TARGET_RT_MAC_CFM := FALSE}
 
102
{$setc TARGET_RT_MAC_MACHO := TRUE}
 
103
{$setc TYPED_FUNCTION_POINTERS := TRUE}
 
104
{$setc TYPE_BOOL := FALSE}
 
105
{$setc TYPE_EXTENDED := FALSE}
 
106
{$setc TYPE_LONGLONG := TRUE}
 
107
uses MacTypes;
 
108
 
 
109
 
 
110
{$ALIGN MAC68K}
 
111
 
 
112
 
 
113
const
 
114
        fixed1                                          = $00010000;
 
115
        fract1                                          = $40000000;
 
116
        positiveInfinity                        = $7FFFFFFF;
 
117
        negativeInfinity                        = $80000000;
 
118
 
 
119
        {       
 
120
            FixRatio, FixMul, and FixRound were previously in ToolUtils.h
 
121
                }
 
122
        {
 
123
         *  FixRatio()
 
124
         *  
 
125
         *  Availability:
 
126
         *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
127
         *    CarbonLib:        in CarbonLib 1.0 and later
 
128
         *    Mac OS X:         in version 10.0 and later
 
129
                }
 
130
function FixRatio(numer: SInt16; denom: SInt16): Fixed; external name '_FixRatio';
 
131
{
 
132
 *  FixMul()
 
133
 *  
 
134
 *  Availability:
 
135
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
136
 *    CarbonLib:        in CarbonLib 1.0 and later
 
137
 *    Mac OS X:         in version 10.0 and later
 
138
 }
 
139
function FixMul(a: Fixed; b: Fixed): Fixed; external name '_FixMul';
 
140
{
 
141
 *  FixRound()
 
142
 *  
 
143
 *  Availability:
 
144
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
145
 *    CarbonLib:        in CarbonLib 1.0 and later
 
146
 *    Mac OS X:         in version 10.0 and later
 
147
 }
 
148
function FixRound(x: Fixed): SInt16; external name '_FixRound';
 
149
{
 
150
 *  Fix2Frac()
 
151
 *  
 
152
 *  Availability:
 
153
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
154
 *    CarbonLib:        in CarbonLib 1.0 and later
 
155
 *    Mac OS X:         in version 10.0 and later
 
156
 }
 
157
function Fix2Frac(x: Fixed): Fract; external name '_Fix2Frac';
 
158
{
 
159
 *  Fix2Long()
 
160
 *  
 
161
 *  Availability:
 
162
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
163
 *    CarbonLib:        in CarbonLib 1.0 and later
 
164
 *    Mac OS X:         in version 10.0 and later
 
165
 }
 
166
function Fix2Long(x: Fixed): SInt32; external name '_Fix2Long';
 
167
{
 
168
 *  Long2Fix()
 
169
 *  
 
170
 *  Availability:
 
171
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
172
 *    CarbonLib:        in CarbonLib 1.0 and later
 
173
 *    Mac OS X:         in version 10.0 and later
 
174
 }
 
175
function Long2Fix(x: SInt32): Fixed; external name '_Long2Fix';
 
176
{
 
177
 *  Frac2Fix()
 
178
 *  
 
179
 *  Availability:
 
180
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
181
 *    CarbonLib:        in CarbonLib 1.0 and later
 
182
 *    Mac OS X:         in version 10.0 and later
 
183
 }
 
184
function Frac2Fix(x: Fract): Fixed; external name '_Frac2Fix';
 
185
{
 
186
 *  FracMul()
 
187
 *  
 
188
 *  Availability:
 
189
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
190
 *    CarbonLib:        in CarbonLib 1.0 and later
 
191
 *    Mac OS X:         in version 10.0 and later
 
192
 }
 
193
function FracMul(x: Fract; y: Fract): Fract; external name '_FracMul';
 
194
{
 
195
 *  FixDiv()
 
196
 *  
 
197
 *  Availability:
 
198
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
199
 *    CarbonLib:        in CarbonLib 1.0 and later
 
200
 *    Mac OS X:         in version 10.0 and later
 
201
 }
 
202
function FixDiv(x: Fixed; y: Fixed): Fixed; external name '_FixDiv';
 
203
{
 
204
 *  FracDiv()
 
205
 *  
 
206
 *  Availability:
 
207
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
208
 *    CarbonLib:        in CarbonLib 1.0 and later
 
209
 *    Mac OS X:         in version 10.0 and later
 
210
 }
 
211
function FracDiv(x: Fract; y: Fract): Fract; external name '_FracDiv';
 
212
{
 
213
 *  FracSqrt()
 
214
 *  
 
215
 *  Availability:
 
216
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
217
 *    CarbonLib:        in CarbonLib 1.0 and later
 
218
 *    Mac OS X:         in version 10.0 and later
 
219
 }
 
220
function FracSqrt(x: Fract): Fract; external name '_FracSqrt';
 
221
{
 
222
 *  FracSin()
 
223
 *  
 
224
 *  Availability:
 
225
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
226
 *    CarbonLib:        in CarbonLib 1.0 and later
 
227
 *    Mac OS X:         in version 10.0 and later
 
228
 }
 
229
function FracSin(x: Fixed): Fract; external name '_FracSin';
 
230
{
 
231
 *  FracCos()
 
232
 *  
 
233
 *  Availability:
 
234
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
235
 *    CarbonLib:        in CarbonLib 1.0 and later
 
236
 *    Mac OS X:         in version 10.0 and later
 
237
 }
 
238
function FracCos(x: Fixed): Fract; external name '_FracCos';
 
239
{
 
240
 *  FixATan2()
 
241
 *  
 
242
 *  Availability:
 
243
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
244
 *    CarbonLib:        in CarbonLib 1.0 and later
 
245
 *    Mac OS X:         in version 10.0 and later
 
246
 }
 
247
function FixATan2(x: SInt32; y: SInt32): Fixed; external name '_FixATan2';
 
248
{
 
249
    Frac2X, Fix2X, X2Fix, and X2Frac translate to and from
 
250
    the floating point type "extended" (that's what the X is for).
 
251
    On the original Mac this was 80-bits and the functions could be
 
252
    accessed via A-Traps.  When the 68881 co-processor was added,
 
253
    it used 96-bit floating point types, so the A-Traps could not 
 
254
    be used.  When PowerPC was added, it used 64-bit floating point
 
255
    types, so yet another prototype was added.
 
256
}
 
257
{$ifc TARGET_CPU_68K}
 
258
{$ifc TARGET_RT_MAC_68881}
 
259
{$ifc CALL_NOT_IN_CARBON}
 
260
{
 
261
 *  Frac2X()
 
262
 *  
 
263
 *  Availability:
 
264
 *    Non-Carbon CFM:   not available
 
265
 *    CarbonLib:        not available
 
266
 *    Mac OS X:         not available
 
267
 }
 
268
function Frac2X(x: Fract): extended; external name '_Frac2X';
 
269
 
 
270
{
 
271
 *  Fix2X()
 
272
 *  
 
273
 *  Availability:
 
274
 *    Non-Carbon CFM:   not available
 
275
 *    CarbonLib:        not available
 
276
 *    Mac OS X:         not available
 
277
 }
 
278
function Fix2X(x: Fixed): extended; external name '_Fix2X';
 
279
 
 
280
{
 
281
 *  X2Fix()
 
282
 *  
 
283
 *  Availability:
 
284
 *    Non-Carbon CFM:   not available
 
285
 *    CarbonLib:        not available
 
286
 *    Mac OS X:         not available
 
287
 }
 
288
function X2Fix(x: extended): Fixed; external name '_X2Fix';
 
289
 
 
290
{
 
291
 *  X2Frac()
 
292
 *  
 
293
 *  Availability:
 
294
 *    Non-Carbon CFM:   not available
 
295
 *    CarbonLib:        not available
 
296
 *    Mac OS X:         not available
 
297
 }
 
298
function X2Frac(x: extended): Fract; external name '_X2Frac';
 
299
 
 
300
{$endc}  {CALL_NOT_IN_CARBON}
 
301
{$elsec}
 
302
{$ifc CALL_NOT_IN_CARBON}
 
303
{
 
304
 *  Frac2X()
 
305
 *  
 
306
 *  Availability:
 
307
 *    Non-Carbon CFM:   not available
 
308
 *    CarbonLib:        not available
 
309
 *    Mac OS X:         not available
 
310
 }
 
311
function Frac2X(x: Fract): extended; external name '_Frac2X';
 
312
{
 
313
 *  Fix2X()
 
314
 *  
 
315
 *  Availability:
 
316
 *    Non-Carbon CFM:   not available
 
317
 *    CarbonLib:        not available
 
318
 *    Mac OS X:         not available
 
319
 }
 
320
function Fix2X(x: Fixed): extended; external name '_Fix2X';
 
321
{
 
322
 *  X2Fix()
 
323
 *  
 
324
 *  Availability:
 
325
 *    Non-Carbon CFM:   not available
 
326
 *    CarbonLib:        not available
 
327
 *    Mac OS X:         not available
 
328
 }
 
329
function X2Fix(x: extended): Fixed; external name '_X2Fix';
 
330
{
 
331
 *  X2Frac()
 
332
 *  
 
333
 *  Availability:
 
334
 *    Non-Carbon CFM:   not available
 
335
 *    CarbonLib:        not available
 
336
 *    Mac OS X:         not available
 
337
 }
 
338
function X2Frac(x: extended): Fract; external name '_X2Frac';
 
339
{$endc}  {CALL_NOT_IN_CARBON}
 
340
{$endc}  {TARGET_RT_MAC_68881}
 
341
{$elsec}
 
342
{
 
343
 *  Frac2X()
 
344
 *  
 
345
 *  Availability:
 
346
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
347
 *    CarbonLib:        in CarbonLib 1.0 and later
 
348
 *    Mac OS X:         in version 10.0 and later
 
349
 }
 
350
function Frac2X(x: Fract): Double; external name '_Frac2X';
 
351
 
 
352
{
 
353
 *  Fix2X()
 
354
 *  
 
355
 *  Availability:
 
356
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
357
 *    CarbonLib:        in CarbonLib 1.0 and later
 
358
 *    Mac OS X:         in version 10.0 and later
 
359
 }
 
360
function Fix2X(x: Fixed): Double; external name '_Fix2X';
 
361
 
 
362
{
 
363
 *  X2Fix()
 
364
 *  
 
365
 *  Availability:
 
366
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
367
 *    CarbonLib:        in CarbonLib 1.0 and later
 
368
 *    Mac OS X:         in version 10.0 and later
 
369
 }
 
370
function X2Fix(x: Double): Fixed; external name '_X2Fix';
 
371
 
 
372
{
 
373
 *  X2Frac()
 
374
 *  
 
375
 *  Availability:
 
376
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
377
 *    CarbonLib:        in CarbonLib 1.0 and later
 
378
 *    Mac OS X:         in version 10.0 and later
 
379
 }
 
380
function X2Frac(x: Double): Fract; external name '_X2Frac';
 
381
 
 
382
{$endc}  {TARGET_CPU_68K}
 
383
 
 
384
{  QuickTime 3.0 makes these Wide routines available on other platforms }
 
385
{$ifc TARGET_CPU_PPC OR NOT TARGET_OS_MAC}
 
386
{
 
387
 *  WideCompare()
 
388
 *  
 
389
 *  Availability:
 
390
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
391
 *    CarbonLib:        in CarbonLib 1.0 and later
 
392
 *    Mac OS X:         in version 10.0 and later
 
393
 }
 
394
function WideCompare(const (*var*) target: wide; const (*var*) source: wide): SInt16; external name '_WideCompare';
 
395
 
 
396
{
 
397
 *  WideAdd()
 
398
 *  
 
399
 *  Availability:
 
400
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
401
 *    CarbonLib:        in CarbonLib 1.0 and later
 
402
 *    Mac OS X:         in version 10.0 and later
 
403
 }
 
404
function WideAdd(var target: wide; const (*var*) source: wide): widePtr; external name '_WideAdd';
 
405
 
 
406
{
 
407
 *  WideSubtract()
 
408
 *  
 
409
 *  Availability:
 
410
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
411
 *    CarbonLib:        in CarbonLib 1.0 and later
 
412
 *    Mac OS X:         in version 10.0 and later
 
413
 }
 
414
function WideSubtract(var target: wide; const (*var*) source: wide): widePtr; external name '_WideSubtract';
 
415
 
 
416
{
 
417
 *  WideNegate()
 
418
 *  
 
419
 *  Availability:
 
420
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
421
 *    CarbonLib:        in CarbonLib 1.0 and later
 
422
 *    Mac OS X:         in version 10.0 and later
 
423
 }
 
424
function WideNegate(var target: wide): widePtr; external name '_WideNegate';
 
425
 
 
426
{
 
427
 *  WideShift()
 
428
 *  
 
429
 *  Availability:
 
430
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
431
 *    CarbonLib:        in CarbonLib 1.0 and later
 
432
 *    Mac OS X:         in version 10.0 and later
 
433
 }
 
434
function WideShift(var target: wide; shift: SInt32): widePtr; external name '_WideShift';
 
435
 
 
436
{
 
437
 *  WideSquareRoot()
 
438
 *  
 
439
 *  Availability:
 
440
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
441
 *    CarbonLib:        in CarbonLib 1.0 and later
 
442
 *    Mac OS X:         in version 10.0 and later
 
443
 }
 
444
function WideSquareRoot(const (*var*) source: wide): UInt32; external name '_WideSquareRoot';
 
445
 
 
446
{
 
447
 *  WideMultiply()
 
448
 *  
 
449
 *  Availability:
 
450
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
451
 *    CarbonLib:        in CarbonLib 1.0 and later
 
452
 *    Mac OS X:         in version 10.0 and later
 
453
 }
 
454
function WideMultiply(multiplicand: SInt32; multiplier: SInt32; var target: wide): widePtr; external name '_WideMultiply';
 
455
 
 
456
{ returns the quotient }
 
457
{
 
458
 *  WideDivide()
 
459
 *  
 
460
 *  Availability:
 
461
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
462
 *    CarbonLib:        in CarbonLib 1.0 and later
 
463
 *    Mac OS X:         in version 10.0 and later
 
464
 }
 
465
function WideDivide(const (*var*) dividend: wide; divisor: SInt32; var remainder: SInt32): SInt32; external name '_WideDivide';
 
466
 
 
467
{ quotient replaces dividend }
 
468
{
 
469
 *  WideWideDivide()
 
470
 *  
 
471
 *  Availability:
 
472
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
473
 *    CarbonLib:        in CarbonLib 1.0 and later
 
474
 *    Mac OS X:         in version 10.0 and later
 
475
 }
 
476
function WideWideDivide(var dividend: wide; divisor: SInt32; var remainder: SInt32): widePtr; external name '_WideWideDivide';
 
477
 
 
478
{
 
479
 *  WideBitShift()
 
480
 *  
 
481
 *  Availability:
 
482
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 
483
 *    CarbonLib:        in CarbonLib 1.0 and later
 
484
 *    Mac OS X:         in version 10.0 and later
 
485
 }
 
486
function WideBitShift(var src: wide; shift: SInt32): widePtr; external name '_WideBitShift';
 
487
 
 
488
{$endc}
 
489
 
 
490
 
 
491
{$ALIGN MAC68K}
 
492
 
 
493
 
 
494
end.