3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2008, Sven-Ola Tuecke (sven-ola@gmx.de)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
48 * The standard math should function with only 32 bits
51 typedef signed long sfpm;
52 typedef unsigned long ufpm;
55 #define FPM_NUM (1 << FPM_BIT)
56 #define FPM_MSK (FPM_NUM - 1)
57 #define FPM_MAX ((sfpm)(~(ufpm)0 >> 1) >> FPM_BIT)
58 #define FPM_MIN ((sfpm)-1 - FPM_MAX)
59 #define FPM_INT_MAX ((sfpm)(~(ufpm)0 >> 1))
60 #define FPM_INT_MIN ((sfpm)-1 - FPM_INT_MAX)
62 #define itofpm_def(a) (fpm)((sfpm)((a) << FPM_BIT))
63 #define ftofpm_def(a) (fpm)((sfpm)((a) * FPM_NUM))
64 #define fpmtoi_def(a) (int)((sfpm)(a) >> FPM_BIT)
65 #define fpmtof_def(a) ((float)(sfpm)(a) / FPM_NUM)
67 #define fpmadd_def(a, b) (fpm)((sfpm)(a) + (sfpm)(b))
68 #define fpmsub_def(a, b) (fpm)((sfpm)(a) - (sfpm)(b))
69 #define fpmmul_def(a, b) (fpm)(((sfpm)(a) * (sfpm)(b)) >> FPM_BIT)
70 #define fpmdiv_def(a, b) (fpm)(((sfpm)(a) << FPM_BIT) / (sfpm)(b))
73 * Special: first or second factor is an integer
75 #define fpmimul_def(a, b) (fpm)((int)(a) * (sfpm)(b))
76 #define fpmmuli_def(a, b) (fpm)((sfpm)(a) * (int)(b))
79 * Special: divisor is an integer
81 #define fpmidiv_def(a, b) (fpm)((sfpm)(a) / (int)(b))
85 #define itofpm itofpm_def
86 #define ftofpm ftofpm_def
87 #define fpmtoi fpmtoi_def
88 #define fpmtof fpmtof_def
90 #define fpmadd fpmadd_def
91 #define fpmsub fpmsub_def
92 #define fpmmul fpmmul_def
93 #define fpmdiv fpmdiv_def
94 #define fpmimul fpmimul_def
95 #define fpmmuli fpmmuli_def
96 #define fpmidiv fpmidiv_def
105 fpm fpmadd(fpm a, fpm b);
106 fpm fpmsub(fpm a, fpm b);
107 fpm fpmmul(fpm a, fpm b);
108 fpm fpmdiv(fpm a, fpm b);
109 fpm fpmimul(int a, fpm b);
110 fpm fpmmuli(fpm a, int b);
111 fpm fpmidiv(fpm a, int b);
115 #define INFINITE_ETX itofpm(FPM_MAX)
116 #define MIN_LINK_QUALITY ftofpm(0.01)
117 #define ZERO_ETX itofpm(0)
118 #define CEIL_LQDIFF ftofpm(1.1)
119 #define FLOOR_LQDIFF ftofpm(0.9)
121 fpm atofpm(const char *);
122 const char *fpmtoa(fpm);
126 #define INFINITE_ETX ((float)(1 << 30))
128 #define MIN_LINK_QUALITY 0.01
129 #define CEIL_LQDIFF 1.1
130 #define FLOOR_LQDIFF 0.9
132 float atofpm(const char *);
133 const char *fpmtoa(float);
142 * indent-tabs-mode: nil