- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,161 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2010 iptelorg GmbH |
|
3 |
- * |
|
4 |
- * Permission to use, copy, modify, and distribute this software for any |
|
5 |
- * purpose with or without fee is hereby granted, provided that the above |
|
6 |
- * copyright notice and this permission notice appear in all copies. |
|
7 |
- * |
|
8 |
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
9 |
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
10 |
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
11 |
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
12 |
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
13 |
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
14 |
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
15 |
- * |
|
16 |
- */ |
|
17 |
- |
|
18 |
-/** Kamailio core :: Bit test functions |
|
19 |
- * @ingroup core |
|
20 |
- * Module: core |
|
21 |
- * |
|
22 |
- * Bit test functions: |
|
23 |
- * - int bit_test(int offset, unsigned int *addr) |
|
24 |
- * Returns the bit found at offset position |
|
25 |
- * in a bitstring pointed by addr. |
|
26 |
- * |
|
27 |
- * - int bit_test_and_set(int offset, unsigned int *addr) |
|
28 |
- * Returns the bit found at offset position |
|
29 |
- * in a bitstring pointed by addr, and sets |
|
30 |
- * the bit at the given offset. |
|
31 |
- * |
|
32 |
- * - int bit_test_and_reset(int offset, unsigned int *addr) |
|
33 |
- * Returns the bit found at offset position |
|
34 |
- * in a bitstring pointed by addr, and resets |
|
35 |
- * the bit at the given offset. |
|
36 |
- * |
|
37 |
- * Note that 0 <= offset <= 128, Make sure that addr points to |
|
38 |
- * a large enough memory area. |
|
39 |
- */ |
|
40 |
- |
|
41 |
-#ifndef _BIT_TEST_H |
|
42 |
-#define _BIT_TEST_H |
|
43 |
- |
|
44 |
-/* fix __CPU_i386 -> __CPU_x86 */ |
|
45 |
-#if defined __CPU_i386 && ! defined __CPU_x86 |
|
46 |
-#define __CPU_x86 |
|
47 |
-#endif |
|
48 |
- |
|
49 |
-#ifdef CC_GCC_LIKE_ASM |
|
50 |
-#if defined __CPU_x86 || defined __CPU_x86_64 |
|
51 |
-#define BIT_TEST_ASM |
|
52 |
-#endif |
|
53 |
-#endif |
|
54 |
- |
|
55 |
-#ifdef BIT_TEST_ASM |
|
56 |
- |
|
57 |
-/* Returns the bit found at offset position in the bitstring |
|
58 |
- * pointed by addr. |
|
59 |
- * Note that the CPU can access 4 bytes starting from addr, |
|
60 |
- * hence 0 <= offset < 128 holds. Make sure that addr points |
|
61 |
- * to a memory area that is large enough. |
|
62 |
- */ |
|
63 |
-static inline int bit_test(int offset, unsigned int *addr) |
|
64 |
-{ |
|
65 |
- unsigned char v; |
|
66 |
- |
|
67 |
- asm volatile( |
|
68 |
- " bt %2, %1 \n\t" |
|
69 |
- " setc %0 \n\t" |
|
70 |
- : "=qm" (v) : "m" (*addr), "r" (offset) |
|
71 |
- ); |
|
72 |
- return (int)v; |
|
73 |
-} |
|
74 |
- |
|
75 |
-/* Returns the bit found at offset position in the bitstring |
|
76 |
- * pointed by addr and sets it to 1. |
|
77 |
- * Note that the CPU can access 4 bytes starting from addr, |
|
78 |
- * hence 0 <= offset < 128 holds. Make sure that addr points |
|
79 |
- * to a memory area that is large enough. |
|
80 |
- */ |
|
81 |
-static inline int bit_test_and_set(int offset, unsigned int *addr) |
|
82 |
-{ |
|
83 |
- unsigned char v; |
|
84 |
- |
|
85 |
- asm volatile( |
|
86 |
- " bts %2, %1 \n\t" |
|
87 |
- " setc %0 \n\t" |
|
88 |
- : "=qm" (v) : "m" (*addr), "r" (offset) |
|
89 |
- ); |
|
90 |
- return (int)v; |
|
91 |
-} |
|
92 |
- |
|
93 |
-/* Returns the bit found at offset position in the bitstring |
|
94 |
- * pointed by addr and resets it to 0. |
|
95 |
- * Note that the CPU can access 4 bytes starting from addr, |
|
96 |
- * hence 0 <= offset < 128 holds. Make sure that addr points |
|
97 |
- * to a memory area that is large enough. |
|
98 |
- */ |
|
99 |
-static inline int bit_test_and_reset(int offset, unsigned int *addr) |
|
100 |
-{ |
|
101 |
- unsigned char v; |
|
102 |
- |
|
103 |
- asm volatile( |
|
104 |
- " btr %2, %1 \n\t" |
|
105 |
- " setc %0 \n\t" |
|
106 |
- : "=qm" (v) : "m" (*addr), "r" (offset) |
|
107 |
- ); |
|
108 |
- return (int)v; |
|
109 |
-} |
|
110 |
- |
|
111 |
-#else /* BIT_TEST_ASM */ |
|
112 |
- |
|
113 |
-/* Returns the bit found at offset position in the bitstring |
|
114 |
- * pointed by addr. |
|
115 |
- * Note that offset can be grater than 32, make sure that addr points |
|
116 |
- * to a memory area that is large enough. |
|
117 |
- */ |
|
118 |
-static inline int bit_test(int offset, unsigned int *addr) |
|
119 |
-{ |
|
120 |
- return ((*(addr + offset/32)) & (1U << (offset % 32))) ? 1 : 0; |
|
121 |
-} |
|
122 |
- |
|
123 |
-/* Returns the bit found at offset position in the bitstring |
|
124 |
- * pointed by addr and sets it to 1. |
|
125 |
- * Note that offset can be grater than 32, make sure that addr points |
|
126 |
- * to a memory area that is large enough. |
|
127 |
- */ |
|
128 |
-static inline int bit_test_and_set(int offset, unsigned int *addr) |
|
129 |
-{ |
|
130 |
- unsigned int *i; |
|
131 |
- int mask, res; |
|
132 |
- |
|
133 |
- i = addr + offset/32; |
|
134 |
- mask = 1U << (offset % 32); |
|
135 |
- res = ((*i) & mask) ? 1 : 0; |
|
136 |
- (*i) |= mask; |
|
137 |
- |
|
138 |
- return res; |
|
139 |
-} |
|
140 |
- |
|
141 |
-/* Returns the bit found at offset position in the bitstring |
|
142 |
- * pointed by addr and resets it to 0. |
|
143 |
- * Note that offset can be grater than 32, make sure that addr points |
|
144 |
- * to a memory area that is large enough. |
|
145 |
- */ |
|
146 |
-static inline int bit_test_and_reset(int offset, unsigned int *addr) |
|
147 |
-{ |
|
148 |
- unsigned int *i; |
|
149 |
- int mask, res; |
|
150 |
- |
|
151 |
- i = addr + offset/32; |
|
152 |
- mask = 1U << (offset % 32); |
|
153 |
- res = ((*i) & mask) ? 1 : 0; |
|
154 |
- (*i) &= ~mask; |
|
155 |
- |
|
156 |
- return res; |
|
157 |
-} |
|
158 |
- |
|
159 |
-#endif /* BIT_TEST_ASM */ |
|
160 |
- |
|
161 |
-#endif /* #ifndef _BIT_TEST_H */ |
... | ... |
@@ -1,6 +1,4 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* Copyright (C) 2010 iptelorg GmbH |
5 | 3 |
* |
6 | 4 |
* Permission to use, copy, modify, and distribute this software for any |
... | ... |
@@ -15,13 +13,13 @@ |
15 | 13 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | 14 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | 15 |
* |
18 |
- * History |
|
19 |
- * ------- |
|
20 |
- * 2010-04-26 Initial version (Miklos) |
|
21 |
- * 2011-01-05 bit_test_and_reset added (Miklos) |
|
22 | 16 |
*/ |
23 | 17 |
|
24 |
-/* Bit test functions: |
|
18 |
+/** Kamailio core :: Bit test functions |
|
19 |
+ * @ingroup core |
|
20 |
+ * Module: core |
|
21 |
+ * |
|
22 |
+ * Bit test functions: |
|
25 | 23 |
* - int bit_test(int offset, unsigned int *addr) |
26 | 24 |
* Returns the bit found at offset position |
27 | 25 |
* in a bitstring pointed by addr. |
The function returns the bit found at offset position
in a bitstring and resets the bit to 0.
... | ... |
@@ -18,6 +18,7 @@ |
18 | 18 |
* History |
19 | 19 |
* ------- |
20 | 20 |
* 2010-04-26 Initial version (Miklos) |
21 |
+ * 2011-01-05 bit_test_and_reset added (Miklos) |
|
21 | 22 |
*/ |
22 | 23 |
|
23 | 24 |
/* Bit test functions: |
... | ... |
@@ -30,6 +31,11 @@ |
30 | 31 |
* in a bitstring pointed by addr, and sets |
31 | 32 |
* the bit at the given offset. |
32 | 33 |
* |
34 |
+ * - int bit_test_and_reset(int offset, unsigned int *addr) |
|
35 |
+ * Returns the bit found at offset position |
|
36 |
+ * in a bitstring pointed by addr, and resets |
|
37 |
+ * the bit at the given offset. |
|
38 |
+ * |
|
33 | 39 |
* Note that 0 <= offset <= 128, Make sure that addr points to |
34 | 40 |
* a large enough memory area. |
35 | 41 |
*/ |
... | ... |
@@ -86,6 +92,24 @@ static inline int bit_test_and_set(int offset, unsigned int *addr) |
86 | 92 |
return (int)v; |
87 | 93 |
} |
88 | 94 |
|
95 |
+/* Returns the bit found at offset position in the bitstring |
|
96 |
+ * pointed by addr and resets it to 0. |
|
97 |
+ * Note that the CPU can access 4 bytes starting from addr, |
|
98 |
+ * hence 0 <= offset < 128 holds. Make sure that addr points |
|
99 |
+ * to a memory area that is large enough. |
|
100 |
+ */ |
|
101 |
+static inline int bit_test_and_reset(int offset, unsigned int *addr) |
|
102 |
+{ |
|
103 |
+ unsigned char v; |
|
104 |
+ |
|
105 |
+ asm volatile( |
|
106 |
+ " btr %2, %1 \n\t" |
|
107 |
+ " setc %0 \n\t" |
|
108 |
+ : "=qm" (v) : "m" (*addr), "r" (offset) |
|
109 |
+ ); |
|
110 |
+ return (int)v; |
|
111 |
+} |
|
112 |
+ |
|
89 | 113 |
#else /* BIT_TEST_ASM */ |
90 | 114 |
|
91 | 115 |
/* Returns the bit found at offset position in the bitstring |
... | ... |
@@ -116,6 +140,24 @@ static inline int bit_test_and_set(int offset, unsigned int *addr) |
116 | 140 |
return res; |
117 | 141 |
} |
118 | 142 |
|
143 |
+/* Returns the bit found at offset position in the bitstring |
|
144 |
+ * pointed by addr and resets it to 0. |
|
145 |
+ * Note that offset can be grater than 32, make sure that addr points |
|
146 |
+ * to a memory area that is large enough. |
|
147 |
+ */ |
|
148 |
+static inline int bit_test_and_reset(int offset, unsigned int *addr) |
|
149 |
+{ |
|
150 |
+ unsigned int *i; |
|
151 |
+ int mask, res; |
|
152 |
+ |
|
153 |
+ i = addr + offset/32; |
|
154 |
+ mask = 1U << (offset % 32); |
|
155 |
+ res = ((*i) & mask) ? 1 : 0; |
|
156 |
+ (*i) &= ~mask; |
|
157 |
+ |
|
158 |
+ return res; |
|
159 |
+} |
|
160 |
+ |
|
119 | 161 |
#endif /* BIT_TEST_ASM */ |
120 | 162 |
|
121 | 163 |
#endif /* #ifndef _BIT_TEST_H */ |
new functions for bit operations:
- bit_count()
- bit_test()
- bit_test_and_set()
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,121 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Copyright (C) 2010 iptelorg GmbH |
|
5 |
+ * |
|
6 |
+ * Permission to use, copy, modify, and distribute this software for any |
|
7 |
+ * purpose with or without fee is hereby granted, provided that the above |
|
8 |
+ * copyright notice and this permission notice appear in all copies. |
|
9 |
+ * |
|
10 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
11 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
12 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
13 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
14 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
15 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
16 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
17 |
+ * |
|
18 |
+ * History |
|
19 |
+ * ------- |
|
20 |
+ * 2010-04-26 Initial version (Miklos) |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+/* Bit test functions: |
|
24 |
+ * - int bit_test(int offset, unsigned int *addr) |
|
25 |
+ * Returns the bit found at offset position |
|
26 |
+ * in a bitstring pointed by addr. |
|
27 |
+ * |
|
28 |
+ * - int bit_test_and_set(int offset, unsigned int *addr) |
|
29 |
+ * Returns the bit found at offset position |
|
30 |
+ * in a bitstring pointed by addr, and sets |
|
31 |
+ * the bit at the given offset. |
|
32 |
+ * |
|
33 |
+ * Note that 0 <= offset <= 128, Make sure that addr points to |
|
34 |
+ * a large enough memory area. |
|
35 |
+ */ |
|
36 |
+ |
|
37 |
+#ifndef _BIT_TEST_H |
|
38 |
+#define _BIT_TEST_H |
|
39 |
+ |
|
40 |
+/* fix __CPU_i386 -> __CPU_x86 */ |
|
41 |
+#if defined __CPU_i386 && ! defined __CPU_x86 |
|
42 |
+#define __CPU_x86 |
|
43 |
+#endif |
|
44 |
+ |
|
45 |
+#ifdef CC_GCC_LIKE_ASM |
|
46 |
+#if defined __CPU_x86 || defined __CPU_x86_64 |
|
47 |
+#define BIT_TEST_ASM |
|
48 |
+#endif |
|
49 |
+#endif |
|
50 |
+ |
|
51 |
+#ifdef BIT_TEST_ASM |
|
52 |
+ |
|
53 |
+/* Returns the bit found at offset position in the bitstring |
|
54 |
+ * pointed by addr. |
|
55 |
+ * Note that the CPU can access 4 bytes starting from addr, |
|
56 |
+ * hence 0 <= offset < 128 holds. Make sure that addr points |
|
57 |
+ * to a memory area that is large enough. |
|
58 |
+ */ |
|
59 |
+static inline int bit_test(int offset, unsigned int *addr) |
|
60 |
+{ |
|
61 |
+ unsigned char v; |
|
62 |
+ |
|
63 |
+ asm volatile( |
|
64 |
+ " bt %2, %1 \n\t" |
|
65 |
+ " setc %0 \n\t" |
|
66 |
+ : "=qm" (v) : "m" (*addr), "r" (offset) |
|
67 |
+ ); |
|
68 |
+ return (int)v; |
|
69 |
+} |
|
70 |
+ |
|
71 |
+/* Returns the bit found at offset position in the bitstring |
|
72 |
+ * pointed by addr and sets it to 1. |
|
73 |
+ * Note that the CPU can access 4 bytes starting from addr, |
|
74 |
+ * hence 0 <= offset < 128 holds. Make sure that addr points |
|
75 |
+ * to a memory area that is large enough. |
|
76 |
+ */ |
|
77 |
+static inline int bit_test_and_set(int offset, unsigned int *addr) |
|
78 |
+{ |
|
79 |
+ unsigned char v; |
|
80 |
+ |
|
81 |
+ asm volatile( |
|
82 |
+ " bts %2, %1 \n\t" |
|
83 |
+ " setc %0 \n\t" |
|
84 |
+ : "=qm" (v) : "m" (*addr), "r" (offset) |
|
85 |
+ ); |
|
86 |
+ return (int)v; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+#else /* BIT_TEST_ASM */ |
|
90 |
+ |
|
91 |
+/* Returns the bit found at offset position in the bitstring |
|
92 |
+ * pointed by addr. |
|
93 |
+ * Note that offset can be grater than 32, make sure that addr points |
|
94 |
+ * to a memory area that is large enough. |
|
95 |
+ */ |
|
96 |
+static inline int bit_test(int offset, unsigned int *addr) |
|
97 |
+{ |
|
98 |
+ return ((*(addr + offset/32)) & (1U << (offset % 32))) ? 1 : 0; |
|
99 |
+} |
|
100 |
+ |
|
101 |
+/* Returns the bit found at offset position in the bitstring |
|
102 |
+ * pointed by addr and sets it to 1. |
|
103 |
+ * Note that offset can be grater than 32, make sure that addr points |
|
104 |
+ * to a memory area that is large enough. |
|
105 |
+ */ |
|
106 |
+static inline int bit_test_and_set(int offset, unsigned int *addr) |
|
107 |
+{ |
|
108 |
+ unsigned int *i; |
|
109 |
+ int mask, res; |
|
110 |
+ |
|
111 |
+ i = addr + offset/32; |
|
112 |
+ mask = 1U << (offset % 32); |
|
113 |
+ res = ((*i) & mask) ? 1 : 0; |
|
114 |
+ (*i) |= mask; |
|
115 |
+ |
|
116 |
+ return res; |
|
117 |
+} |
|
118 |
+ |
|
119 |
+#endif /* BIT_TEST_ASM */ |
|
120 |
+ |
|
121 |
+#endif /* #ifndef _BIT_TEST_H */ |