"Fossies" - the Fresh Open Source Software Archive 
Member "mapm_4.9.5a/MULTI_THREAD/mapm_mt.c" (21 Feb 2010, 14683 Bytes) of package /linux/misc/old/mapm-4.9.5a.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "mapm_mt.c" see the
Fossies "Dox" file reference documentation.
1
2 /*
3 * M_APM - mapm_mt.c
4 *
5 * Copyright (C) 2002 - 2007
6 * Martin Pfingstl (Martin.Pfingstl@epost.de)
7 * Michael C. Ring
8 *
9 * Permission to use, copy, and distribute this software and its
10 * documentation for any purpose with or without fee is hereby granted,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation.
14 *
15 * Permission to modify the software is granted. Permission to distribute
16 * the modified code is granted. Modifications are to be distributed by
17 * using the file 'license.txt' as a template to modify the file header.
18 * 'license.txt' is available in the official MAPM distribution.
19 *
20 * This software is provided "as is" without express or implied warranty.
21 */
22
23 /*
24 * $Id: mapm_mt.c,v 1.4 2007/12/03 02:24:27 mike Exp $
25 *
26 * This file contains all wrapper functions for the library
27 * using semaphores
28 *
29 * $Log: mapm_mt.c,v $
30 * Revision 1.4 2007/12/03 02:24:27 mike
31 * update license
32 *
33 * Revision 1.3 2003/05/07 22:52:22 mike
34 * add 2 new version functions
35 *
36 * Revision 1.2 2002/11/10 22:42:44 mike
37 * add new integer_pow_nr function
38 *
39 * Revision 1.1 2002/06/13 20:39:09 mike
40 * Initial revision
41 */
42
43
44 #include "m_apm.h"
45
46 extern void m_apm_enter(void);
47 extern void m_apm_leave(void);
48 extern void m_apm_init_semaphore(void);
49 extern void m_apm_free_semaphore(void);
50
51 /* **************************************************************
52 Platform specific stuff
53 ************************************************************** */
54
55
56 #ifdef _MSC_VER /* for micro$oft compilers */
57
58 #include <windows.h>
59 static CRITICAL_SECTION m_apm_semaphore;
60
61 void m_apm_enter(void)
62 {
63 EnterCriticalSection(&m_apm_semaphore);
64 }
65
66 void m_apm_leave(void)
67 {
68 LeaveCriticalSection(&m_apm_semaphore);
69 }
70
71 void m_apm_init_semaphore(void)
72 {
73 InitializeCriticalSection(&m_apm_semaphore);
74 }
75
76 void m_apm_free_semaphore(void)
77 {
78 DeleteCriticalSection(&m_apm_semaphore);
79 }
80
81 #endif
82
83
84 /* *************************************************************
85 END Platform specific stuff
86 ************************************************************* */
87
88
89 /****************************************************************************/
90
91 char *m_apm_lib_version_mt(char *s)
92 {
93 m_apm_enter();
94 m_apm_lib_version(s);
95 m_apm_leave();
96 return(s);
97 }
98
99 /****************************************************************************/
100
101 char *m_apm_lib_short_version_mt(char *s)
102 {
103 m_apm_enter();
104 m_apm_lib_short_version(s);
105 m_apm_leave();
106 return(s);
107 }
108
109 /****************************************************************************/
110
111 M_APM m_apm_init_mt(void)
112 {
113 M_APM t;
114
115 m_apm_enter();
116 t=m_apm_init();
117 m_apm_leave();
118 return(t);
119 }
120
121 /****************************************************************************/
122
123 void m_apm_free_mt(M_APM t)
124 {
125 m_apm_enter();
126 m_apm_free(t);
127 m_apm_leave();
128 }
129
130 /****************************************************************************/
131
132 void m_apm_free_all_mem_mt(void)
133 {
134 m_apm_enter();
135 m_apm_free_all_mem();
136 m_apm_leave();
137 }
138
139 /****************************************************************************/
140
141 void m_apm_trim_mem_usage_mt(void)
142 {
143 m_apm_enter();
144 m_apm_trim_mem_usage();
145 m_apm_leave();
146 }
147
148 /****************************************************************************/
149
150 void m_apm_set_string_mt(M_APM ctmp, char *s_in)
151 {
152 m_apm_enter();
153 m_apm_set_string(ctmp,s_in);
154 m_apm_leave();
155 }
156
157 /****************************************************************************/
158
159 void m_apm_set_double_mt(M_APM atmp,double dd)
160 {
161 m_apm_enter();
162 m_apm_set_double(atmp,dd);
163 m_apm_leave();
164 }
165
166 /****************************************************************************/
167
168 void m_apm_set_long_mt(M_APM atmp, long mm)
169 {
170 m_apm_enter();
171 m_apm_set_long(atmp,mm);
172 m_apm_leave();
173 }
174
175 /****************************************************************************/
176
177 void m_apm_to_string_mt(char *s, int places, M_APM mtmp)
178 {
179 m_apm_enter();
180 m_apm_to_string(s,places,mtmp);
181 m_apm_leave();
182 }
183
184 /****************************************************************************/
185
186 void m_apm_add_mt(M_APM r, M_APM a, M_APM b)
187 {
188 m_apm_enter();
189 m_apm_add(r,a,b);
190 m_apm_leave();
191 }
192
193 /****************************************************************************/
194
195 void m_apm_subtract_mt(M_APM r, M_APM a, M_APM b)
196 {
197 m_apm_enter();
198 m_apm_subtract(r,a,b);
199 m_apm_leave();
200 }
201
202 /****************************************************************************/
203
204 void m_apm_absolute_value_mt(M_APM d, M_APM s)
205 {
206 m_apm_enter();
207 m_apm_absolute_value(d,s);
208 m_apm_leave();
209 }
210
211 /****************************************************************************/
212
213 void m_apm_negate_mt(M_APM d, M_APM s)
214 {
215 m_apm_enter();
216 m_apm_negate(d,s);
217 m_apm_leave();
218 }
219
220 /****************************************************************************/
221
222 int m_apm_compare_mt(M_APM ltmp, M_APM rtmp)
223 {
224 int ret;
225
226 m_apm_enter();
227 ret=m_apm_compare(ltmp,rtmp);
228 m_apm_leave();
229 return(ret);
230 }
231
232
233 /****************************************************************************/
234
235 void m_apm_multiply_mt(M_APM r, M_APM a, M_APM b)
236 {
237 m_apm_enter();
238 m_apm_multiply(r,a,b);
239 m_apm_leave();
240 }
241
242 /****************************************************************************/
243
244 void m_apm_divide_mt(M_APM rr, int places, M_APM aa, M_APM bb)
245 {
246 m_apm_enter();
247 m_apm_divide(rr,places,aa,bb);
248 m_apm_leave();
249 }
250
251 /****************************************************************************/
252
253 void m_apm_cpp_precision_mt(int digits)
254 {
255 m_apm_enter();
256 m_apm_cpp_precision(digits);
257 m_apm_leave();
258 }
259
260 /****************************************************************************/
261
262 void m_apm_to_fixpt_string_mt(char *ss, int dplaces, M_APM mtmp)
263 {
264 m_apm_enter();
265 m_apm_to_fixpt_string(ss,dplaces,mtmp);
266 m_apm_leave();
267 }
268
269 /****************************************************************************/
270
271 void m_apm_round_mt(M_APM btmp, int places, M_APM atmp)
272 {
273 m_apm_enter();
274 m_apm_round(btmp,places,atmp);
275 m_apm_leave();
276 }
277
278 /****************************************************************************/
279
280 void m_apm_sqrt_mt(M_APM rr, int places, M_APM aa)
281 {
282 m_apm_enter();
283 m_apm_sqrt(rr,places,aa);
284 m_apm_leave();
285 }
286
287 /****************************************************************************/
288
289 void m_apm_sin_mt(M_APM r, int places, M_APM a)
290 {
291 m_apm_enter();
292 m_apm_sin(r,places,a);
293 m_apm_leave();
294 }
295
296 /****************************************************************************/
297
298 void m_apm_arccos_mt(M_APM r, int places, M_APM x)
299 {
300 m_apm_enter();
301 m_apm_arccos(r,places,x);
302 m_apm_leave();
303 }
304
305 /****************************************************************************/
306
307 void m_apm_arctan2_mt(M_APM rr, int places, M_APM yy, M_APM xx)
308 {
309 m_apm_enter();
310 m_apm_arctan2(rr,places,yy,xx);
311 m_apm_leave();
312 }
313
314 /****************************************************************************/
315
316 void m_apm_copy_mt(M_APM dest, M_APM src)
317 {
318 m_apm_enter();
319 m_apm_copy(dest,src);
320 m_apm_leave();
321 }
322
323
324 /****************************************************************************/
325
326 void m_apm_reciprocal_mt(M_APM rr, int places, M_APM aa)
327 {
328 m_apm_enter();
329 m_apm_reciprocal(rr,places,aa);
330 m_apm_leave();
331 }
332
333 /****************************************************************************/
334
335 void m_apm_to_fixpt_stringex_mt(char *s, int dplaces, M_APM atmp,
336 char ch_radix, char ch_sep, int count_sep)
337 {
338 m_apm_enter();
339 m_apm_to_fixpt_stringex(s,dplaces,atmp,ch_radix,ch_sep,count_sep);
340 m_apm_leave();
341 }
342
343 /****************************************************************************/
344
345 char *m_apm_to_fixpt_stringexp_mt(int dplaces, M_APM atmp, char ch_radx,
346 char ch_sep, int ct_sep)
347 {
348 char *s;
349
350 m_apm_enter();
351 s=m_apm_to_fixpt_stringexp(dplaces,atmp,ch_radx,ch_sep,ct_sep);
352 m_apm_leave();
353 return(s);
354 }
355
356 /****************************************************************************/
357
358 void m_apm_to_integer_string_mt(char *s, M_APM mtmp)
359 {
360 m_apm_enter();
361 m_apm_to_integer_string(s,mtmp);
362 m_apm_leave();
363 }
364
365 /****************************************************************************/
366
367 int m_apm_sign_mt(M_APM m)
368 {
369 int i;
370
371 m_apm_enter();
372 i=m_apm_sign(m);
373 m_apm_leave();
374 return(i);
375 }
376
377 /****************************************************************************/
378
379 int m_apm_exponent_mt(M_APM m)
380 {
381 int i;
382
383 m_apm_enter();
384 i=m_apm_exponent(m);
385 m_apm_leave();
386 return(i);
387 }
388
389 /****************************************************************************/
390
391 int m_apm_significant_digits_mt(M_APM m)
392 {
393 int i;
394
395 m_apm_enter();
396 i=m_apm_significant_digits(m);
397 m_apm_leave();
398 return(i);
399 }
400
401 /****************************************************************************/
402
403 int m_apm_is_integer_mt(M_APM m)
404 {
405 int i;
406
407 m_apm_enter();
408 i=m_apm_is_integer(m);
409 m_apm_leave();
410 return(i);
411 }
412
413 /****************************************************************************/
414
415 int m_apm_is_even_mt(M_APM m)
416 {
417 int i;
418
419 m_apm_enter();
420 i=m_apm_is_even(m);
421 m_apm_leave();
422 return(i);
423 }
424
425 /****************************************************************************/
426
427 int m_apm_is_odd_mt(M_APM m)
428 {
429 int i;
430
431 m_apm_enter();
432 i=m_apm_is_odd(m);
433 m_apm_leave();
434 return(i);
435 }
436
437 /****************************************************************************/
438
439 void m_apm_gcd_mt(M_APM r, M_APM u, M_APM v)
440 {
441 m_apm_enter();
442 m_apm_gcd(r,u,v);
443 m_apm_leave();
444 }
445
446 /****************************************************************************/
447
448 void m_apm_lcm_mt(M_APM r, M_APM u, M_APM v)
449 {
450 m_apm_enter();
451 m_apm_lcm(r,u,v);
452 m_apm_leave();
453 }
454
455 /****************************************************************************/
456
457 void m_apm_integer_divide_mt(M_APM rr, M_APM aa, M_APM bb)
458 {
459 m_apm_enter();
460 m_apm_integer_divide(rr,aa,bb);
461 m_apm_leave();
462 }
463
464 /****************************************************************************/
465
466 void m_apm_integer_div_rem_mt(M_APM qq, M_APM rr, M_APM aa, M_APM bb)
467 {
468 m_apm_enter();
469 m_apm_integer_div_rem(qq,rr,aa,bb);
470 m_apm_leave();
471 }
472
473 /****************************************************************************/
474
475 void m_apm_factorial_mt(M_APM moutput, M_APM minput)
476 {
477 m_apm_enter();
478 m_apm_factorial(moutput,minput);
479 m_apm_leave();
480 }
481
482 /****************************************************************************/
483
484 void m_apm_floor_mt(M_APM bb, M_APM aa)
485 {
486 m_apm_enter();
487 m_apm_floor(bb,aa);
488 m_apm_leave();
489 }
490
491 /****************************************************************************/
492
493 void m_apm_ceil_mt(M_APM bb, M_APM aa)
494 {
495 m_apm_enter();
496 m_apm_ceil(bb,aa);
497 m_apm_leave();
498 }
499
500 /****************************************************************************/
501
502 void m_apm_get_random_mt(M_APM m)
503 {
504 m_apm_enter();
505 m_apm_get_random(m);
506 m_apm_leave();
507 }
508
509 /****************************************************************************/
510
511 void m_apm_set_random_seed_mt(char *s)
512 {
513 m_apm_enter();
514 m_apm_set_random_seed(s);
515 m_apm_leave();
516 }
517
518 /****************************************************************************/
519
520 void m_apm_cbrt_mt(M_APM rr, int places, M_APM aa)
521 {
522 m_apm_enter();
523 m_apm_cbrt(rr,places,aa);
524 m_apm_leave();
525 }
526
527 /****************************************************************************/
528
529 void m_apm_log_mt(M_APM rr, int places, M_APM aa)
530 {
531 m_apm_enter();
532 m_apm_log(rr,places,aa);
533 m_apm_leave();
534 }
535
536 /****************************************************************************/
537
538 void m_apm_log10_mt(M_APM rr, int places, M_APM aa)
539 {
540 m_apm_enter();
541 m_apm_log10(rr,places,aa);
542 m_apm_leave();
543 }
544
545 /****************************************************************************/
546
547 void m_apm_exp_mt(M_APM rr, int places, M_APM aa)
548 {
549 m_apm_enter();
550 m_apm_exp(rr,places,aa);
551 m_apm_leave();
552 }
553
554 /****************************************************************************/
555
556 void m_apm_pow_mt(M_APM rr, int places, M_APM xx, M_APM yy)
557 {
558 m_apm_enter();
559 m_apm_pow(rr,places,xx,yy);
560 m_apm_leave();
561 }
562
563 /****************************************************************************/
564
565 void m_apm_integer_pow_mt(M_APM rr, int places, M_APM aa, int mexp)
566 {
567 m_apm_enter();
568 m_apm_integer_pow(rr,places,aa,mexp);
569 m_apm_leave();
570 }
571
572 /****************************************************************************/
573
574 void m_apm_integer_pow_nr_mt(M_APM rr, M_APM aa, int mexp)
575 {
576 m_apm_enter();
577 m_apm_integer_pow_nr(rr,aa,mexp);
578 m_apm_leave();
579 }
580
581 /****************************************************************************/
582
583 void m_apm_sin_cos_mt(M_APM sinv, M_APM cosv, int places, M_APM aa)
584 {
585 m_apm_enter();
586 m_apm_sin_cos(sinv,cosv,places,aa);
587 m_apm_leave();
588 }
589
590 /****************************************************************************/
591
592 void m_apm_cos_mt(M_APM rr, int places, M_APM aa)
593 {
594 m_apm_enter();
595 m_apm_cos(rr,places,aa);
596 m_apm_leave();
597 }
598
599 /****************************************************************************/
600
601 void m_apm_tan_mt(M_APM rr, int places, M_APM aa)
602 {
603 m_apm_enter();
604 m_apm_tan(rr,places,aa);
605 m_apm_leave();
606 }
607
608 /****************************************************************************/
609
610 void m_apm_arcsin_mt(M_APM rr, int places, M_APM aa)
611 {
612 m_apm_enter();
613 m_apm_arcsin(rr,places,aa);
614 m_apm_leave();
615 }
616
617 /****************************************************************************/
618
619 void m_apm_arctan_mt(M_APM rr, int places, M_APM aa)
620 {
621 m_apm_enter();
622 m_apm_arctan(rr,places,aa);
623 m_apm_leave();
624 }
625
626 /****************************************************************************/
627
628 void m_apm_sinh_mt(M_APM rr, int places, M_APM aa)
629 {
630 m_apm_enter();
631 m_apm_sinh(rr,places,aa);
632 m_apm_leave();
633 }
634
635 /****************************************************************************/
636
637 void m_apm_cosh_mt(M_APM rr, int places, M_APM aa)
638 {
639 m_apm_enter();
640 m_apm_cosh(rr,places,aa);
641 m_apm_leave();
642 }
643
644 /****************************************************************************/
645
646 void m_apm_tanh_mt(M_APM rr, int places, M_APM aa)
647 {
648 m_apm_enter();
649 m_apm_tanh(rr,places,aa);
650 m_apm_leave();
651 }
652
653 /****************************************************************************/
654
655 void m_apm_arcsinh_mt(M_APM rr, int places, M_APM aa)
656 {
657 m_apm_enter();
658 m_apm_arcsinh(rr,places,aa);
659 m_apm_leave();
660 }
661
662 /****************************************************************************/
663
664 void m_apm_arccosh_mt(M_APM rr, int places, M_APM aa)
665 {
666 m_apm_enter();
667 m_apm_arccosh(rr,places,aa);
668 m_apm_leave();
669 }
670
671 /****************************************************************************/
672
673 void m_apm_arctanh_mt(M_APM rr, int places, M_APM aa)
674 {
675 m_apm_enter();
676 m_apm_arctanh(rr,places,aa);
677 m_apm_leave();
678 }
679
680 /****************************************************************************/
681