Browse code

core, lib, modules: restructured source code tree

- 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)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,160 +0,0 @@
1
-/* 
2
- * Copyright (C) 2008 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
-/** @file
18
- *  Kamailio core :: endianness compile and runtime  tests
19
- *  @author andrei
20
- *  @ingroup core
21
- * 
22
- *
23
- * Defines:
24
- *  -  __IS_LITTLE_ENDIAN if the system is little endian and
25
- *  -  __IS_BIG_ENDIAN    if it's big endian
26
- * Function/macros:
27
- *  -   is_big_endian()  - runtime test for big endian
28
- *  -   is_little_endian() - runtime test for little endian
29
- *  -   endianness_sanity_check() - returns 0 if the compile time
30
- *                                  detected endianness corresponds to
31
- *                                  the runtime detected one and -1 on 
32
- *                                  error (recommended action: bail out)
33
- *  -   bswap16() - 16 bit byte swap
34
- *  -   bswap32() - 32 bit byte swap
35
- *
36
- * Implementation notes:
37
- * Endian macro names/tests for different OSes:
38
- * linux:  __BYTE_ORDER == __LITTLE_ENDIAN | __BIG_ENDIAN
39
- *           BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
40
- * bsd:     _BYTE_ORDER == _LITTLE_ENDIAN | _BIG_ENDIAN
41
- *           BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
42
- * solaris: _LITTLE_ENDIAN | _BIG_ENDIAN
43
- *
44
- * Include file for the endian macros:
45
- * linux: <endian.h> (glibc), <sys/param.h>
46
- * bsd:   <sys/param.h>, <sys/endian.h>
47
- * solaris: <sys/param.h>
48
- *
49
- * Note: BIG_ENDIAN, LITTLE_ENDIAN, _BIG_ENDIAN, _LITTLE_ENDIAN cannot be 
50
- *       used always,  some OSes define both of them for BYTE_ORDER use
51
- *       (e.g. linux defines both BIG_ENDIAN & LITTLE_ENDIAN, bsds define
52
- *          _BIG_ENDIAN, _LITTLE_ENDIAN, BIG_ENDIAN, LITTLE_ENDIAN)
53
- *
54
- */
55
-
56
-
57
-#ifndef _endianness_h
58
-#define _endianness_h
59
-
60
-/* use bsd includes: they work everywhere */
61
-#include <sys/types.h>
62
-#include <sys/param.h>
63
-
64
-
65
-
66
-extern int _endian_test_int;
67
-
68
-/* returns 1 for little endian, 0 for big endian */
69
-#define endian_test()		(*(char*)&_endian_test_int==1)
70
-#define is_big_endian()		(!endian_test())
71
-#define is_little_endian()	endian_test()
72
-
73
-
74
-extern int endianness_sanity_check(void);
75
-
76
-/* detect compile time endianess */
77
-#if defined __BYTE_ORDER && defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
78
-/* linux */
79
-#if __BYTE_ORDER == __LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
80
-	#define __IS_LITTLE_ENDIAN 0x01020304
81
-#endif
82
-#if __BYTE_ORDER == __BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
83
-	#define __IS_BIG_ENDIAN 0x01020304
84
-#endif
85
-#elif defined _BYTE_ORDER && defined _LITTLE_ENDIAN && defined _BIG_ENDIAN
86
-/* bsd */
87
-#if _BYTE_ORDER == _LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
88
-	#define __IS_LITTLE_ENDIAN 0x01020304
89
-#endif
90
-#if _BYTE_ORDER == _BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
91
-	#define __IS_BIG_ENDIAN 0x01020304
92
-#endif
93
-#elif defined BYTE_ORDER && defined LITTLE_ENDIAN && defined BIG_ENDIAN
94
-/* bsd old/deprecated */
95
-#if BYTE_ORDER == LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
96
-	#define __IS_LITTLE_ENDIAN 0x01020304
97
-#endif
98
-#if BYTE_ORDER == BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
99
-	#define __IS_BIG_ENDIAN 0x01020304
100
-#endif
101
-#elif !(defined _LITTLE_ENDIAN && defined _BIG_ENDIAN) && \
102
-		(defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
103
-/* OSes that don't define BYTE_ORDER (sanity check above makes sure
104
- *   little & big endian are not defined in the same time )*/
105
-/* solaris */
106
-#if defined _LITTLE_ENDIAN && !defined __IS_LITTLE_ENDIAN
107
-	#define __IS_LITTLE_ENDIAN 0x01020304
108
-#endif
109
-#if defined _BIG_ENDIAN && !defined __IS_BIG_ENDIAN
110
-	#define __IS_BIG_ENDIAN 0x04030201
111
-#endif
112
-#elif !(defined LITTLE_ENDIAN && defined BIG_ENDIAN) && \
113
-		(defined LITTLE_ENDIAN || defined BIG_ENDIAN)
114
-/* OSes that don't define BYTE_ORDER (sanity check above makes sure
115
- *   little & big endian are not defined in the same time )*/
116
-#if defined LITTLE_ENDIAN && !defined __IS_LITTLE_ENDIAN
117
-	#define __IS_LITTLE_ENDIAN 0x01020304
118
-#endif
119
-#if defined BIG_ENDIAN && !defined __IS_BIG_ENDIAN
120
-	#define __IS_BIG_ENDIAN 0x04030201
121
-#endif
122
-
123
-#else
124
-#error could not detect endianess
125
-#endif
126
-
127
-#if !defined __IS_LITTLE_ENDIAN && !defined __IS_BIG_ENDIAN
128
-#error BUG: could not detect endianess
129
-#endif
130
-
131
-#if defined __IS_LITTLE_ENDIAN && defined __IS_BIG_ENDIAN
132
-#error BUG: both little & big endian detected in the same time
133
-#endif
134
-
135
-#if defined __IS_LITTLE_ENDIAN
136
-#include <arpa/inet.h>
137
-#define bswap16(x) ntohs(x)
138
-#define bswap32(x) ntohl(x)
139
-#else /* !__IS_LITTLE_ENDIAN */
140
-#include <stdint.h>
141
-#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
142
-/* need at least GCC 4.8 for __builtin_bswap16 on all archs */
143
-#define bswap16(x)	((uint16_t)__builtin_bswap16(x))
144
-#else
145
-#define bswap16(x)	(((uint16_t)(x) >> 8) | \
146
-			((uint16_t)(x) << 8))
147
-#endif
148
-#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
149
-/* GCC >= 4.3 provides __builtin_bswap32 */
150
-#define bswap32(x)	((uint32_t)__builtin_bswap32(x))
151
-#else
152
-#define bswap32(x)	(((uint32_t)(x) << 24) | \
153
-			(((uint32_t)(x) << 8) & 0xff0000) | \
154
-			(((uint32_t)(x) >> 8) & 0xff00) | \
155
-			((uint32_t)(x)  >> 24))
156
-#endif
157
-#endif /* !__IS_LITTLE_ENDIAN */
158
-
159
-#endif /* _endianness_h */
160
-
Browse code

core: add generic byte swap macros

- add bswap16() and bswap32() for 16 and 32 bit endianness swap

Spencer Thomason authored on 07/07/2016 08:13:17
Showing 1 changed files
... ...
@@ -30,6 +30,8 @@
30 30
  *                                  detected endianness corresponds to
31 31
  *                                  the runtime detected one and -1 on 
32 32
  *                                  error (recommended action: bail out)
33
+ *  -   bswap16() - 16 bit byte swap
34
+ *  -   bswap32() - 32 bit byte swap
33 35
  *
34 36
  * Implementation notes:
35 37
  * Endian macro names/tests for different OSes:
... ...
@@ -130,6 +132,29 @@ extern int endianness_sanity_check(void);
130 132
 #error BUG: both little & big endian detected in the same time
131 133
 #endif
132 134
 
135
+#if defined __IS_LITTLE_ENDIAN
136
+#include <arpa/inet.h>
137
+#define bswap16(x) ntohs(x)
138
+#define bswap32(x) ntohl(x)
139
+#else /* !__IS_LITTLE_ENDIAN */
140
+#include <stdint.h>
141
+#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
142
+/* need at least GCC 4.8 for __builtin_bswap16 on all archs */
143
+#define bswap16(x)	((uint16_t)__builtin_bswap16(x))
144
+#else
145
+#define bswap16(x)	(((uint16_t)(x) >> 8) | \
146
+			((uint16_t)(x) << 8))
147
+#endif
148
+#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
149
+/* GCC >= 4.3 provides __builtin_bswap32 */
150
+#define bswap32(x)	((uint32_t)__builtin_bswap32(x))
151
+#else
152
+#define bswap32(x)	(((uint32_t)(x) << 24) | \
153
+			(((uint32_t)(x) << 8) & 0xff0000) | \
154
+			(((uint32_t)(x) >> 8) & 0xff00) | \
155
+			((uint32_t)(x)  >> 24))
156
+#endif
157
+#endif /* !__IS_LITTLE_ENDIAN */
133 158
 
134 159
 #endif /* _endianness_h */
135 160
 
Browse code

core : Update include files - delete IDs, update doxygen, delete history

Olle E. Johansson authored on 03/01/2015 10:55:48
Showing 1 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /* 
2
- * $Id$
3
- * 
4 2
  * Copyright (C) 2008 iptelorg GmbH
5 3
  *
6 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -17,11 +15,10 @@
17 15
  */
18 16
 
19 17
 /** @file
20
- *  endianness compile and runtime  tests
18
+ *  Kamailio core :: endianness compile and runtime  tests
19
+ *  @author andrei
20
+ *  @ingroup core
21 21
  * 
22
- * History:
23
- * --------
24
- *  2008-06-13  created by andrei
25 22
  *
26 23
  * Defines:
27 24
  *  -  __IS_LITTLE_ENDIAN if the system is little endian and
Browse code

core: Added void to declarations of functions with empty argument list

In C language, a declaration in the form int f(); is equivalent to int f(...);, thus being able to accept an indefinit number of parameters. With the -Wstrict-prototypes GCC options, these declarations are reported as "function declaration isn’t a prototype".
On some cases, this may trick the compiler into generating unoptimized code (like preparing to handle variadic argument list).
In all cases having a declaration int f() and a definition inf f(int) is missleading, even if standard compliant.
This is still Work in Progress. (maybe adding the -Wstrict-prototypes option to default is desireable)

Marius Zbihlei authored on 02/04/2012 14:19:17
Showing 1 changed files
... ...
@@ -72,7 +72,7 @@ extern int _endian_test_int;
72 72
 #define is_little_endian()	endian_test()
73 73
 
74 74
 
75
-extern int endianness_sanity_check();
75
+extern int endianness_sanity_check(void);
76 76
 
77 77
 /* detect compile time endianess */
78 78
 #if defined __BYTE_ORDER && defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
Browse code

Documentation and doxygen updates

oej authored on 25/10/2009 19:49:25
Showing 1 changed files
... ...
@@ -15,27 +15,25 @@
15 15
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 16
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
  */
18
-/*
18
+
19
+/** @file
19 20
  *  endianness compile and runtime  tests
20 21
  * 
21 22
  * History:
22 23
  * --------
23 24
  *  2008-06-13  created by andrei
24
- */
25
-
26
-/*
25
+ *
27 26
  * Defines:
28
- *    __IS_LITTLE_ENDIAN if the system is little endian and
29
- *    __IS_BIG_ENDIAN    if it's big endian
27
+ *  -  __IS_LITTLE_ENDIAN if the system is little endian and
28
+ *  -  __IS_BIG_ENDIAN    if it's big endian
30 29
  * Function/macros:
31
- *     is_big_endian()  - runtime test for big endian
32
- *     is_little_endian() - runtime test for little endian
33
- *     endianness_sanity_check() - returns 0 if the compile time
30
+ *  -   is_big_endian()  - runtime test for big endian
31
+ *  -   is_little_endian() - runtime test for little endian
32
+ *  -   endianness_sanity_check() - returns 0 if the compile time
34 33
  *                                  detected endianness corresponds to
35 34
  *                                  the runtime detected one and -1 on 
36 35
  *                                  error (recommended action: bail out)
37
- */
38
-/*
36
+ *
39 37
  * Implementation notes:
40 38
  * Endian macro names/tests for different OSes:
41 39
  * linux:  __BYTE_ORDER == __LITTLE_ENDIAN | __BIG_ENDIAN
Browse code

- typo

Andrei Pelinescu-Onciul authored on 01/07/2008 21:56:06
Showing 1 changed files
... ...
@@ -106,7 +106,7 @@ extern int endianness_sanity_check();
106 106
 /* OSes that don't define BYTE_ORDER (sanity check above makes sure
107 107
  *   little & big endian are not defined in the same time )*/
108 108
 /* solaris */
109
-#if defined _LITTLE_ENDIAN && !defined __IS_LITLE_ENDIAN
109
+#if defined _LITTLE_ENDIAN && !defined __IS_LITTLE_ENDIAN
110 110
 	#define __IS_LITTLE_ENDIAN 0x01020304
111 111
 #endif
112 112
 #if defined _BIG_ENDIAN && !defined __IS_BIG_ENDIAN
... ...
@@ -116,7 +116,7 @@ extern int endianness_sanity_check();
116 116
 		(defined LITTLE_ENDIAN || defined BIG_ENDIAN)
117 117
 /* OSes that don't define BYTE_ORDER (sanity check above makes sure
118 118
  *   little & big endian are not defined in the same time )*/
119
-#if defined LITTLE_ENDIAN && !defined __IS_LITLE_ENDIAN
119
+#if defined LITTLE_ENDIAN && !defined __IS_LITTLE_ENDIAN
120 120
 	#define __IS_LITTLE_ENDIAN 0x01020304
121 121
 #endif
122 122
 #if defined BIG_ENDIAN && !defined __IS_BIG_ENDIAN
Browse code

- an attempt at portable endianness macros: __IS_LITTLE_ENDIAN, __IS_BIG_ENDIAN and runtime check/sanity functions

Andrei Pelinescu-Onciul authored on 13/06/2008 20:09:54
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,140 @@
1
+/* 
2
+ * $Id$
3
+ * 
4
+ * Copyright (C) 2008 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
+/*
19
+ *  endianness compile and runtime  tests
20
+ * 
21
+ * History:
22
+ * --------
23
+ *  2008-06-13  created by andrei
24
+ */
25
+
26
+/*
27
+ * Defines:
28
+ *    __IS_LITTLE_ENDIAN if the system is little endian and
29
+ *    __IS_BIG_ENDIAN    if it's big endian
30
+ * Function/macros:
31
+ *     is_big_endian()  - runtime test for big endian
32
+ *     is_little_endian() - runtime test for little endian
33
+ *     endianness_sanity_check() - returns 0 if the compile time
34
+ *                                  detected endianness corresponds to
35
+ *                                  the runtime detected one and -1 on 
36
+ *                                  error (recommended action: bail out)
37
+ */
38
+/*
39
+ * Implementation notes:
40
+ * Endian macro names/tests for different OSes:
41
+ * linux:  __BYTE_ORDER == __LITTLE_ENDIAN | __BIG_ENDIAN
42
+ *           BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
43
+ * bsd:     _BYTE_ORDER == _LITTLE_ENDIAN | _BIG_ENDIAN
44
+ *           BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
45
+ * solaris: _LITTLE_ENDIAN | _BIG_ENDIAN
46
+ *
47
+ * Include file for the endian macros:
48
+ * linux: <endian.h> (glibc), <sys/param.h>
49
+ * bsd:   <sys/param.h>, <sys/endian.h>
50
+ * solaris: <sys/param.h>
51
+ *
52
+ * Note: BIG_ENDIAN, LITTLE_ENDIAN, _BIG_ENDIAN, _LITTLE_ENDIAN cannot be 
53
+ *       used always,  some OSes define both of them for BYTE_ORDER use
54
+ *       (e.g. linux defines both BIG_ENDIAN & LITTLE_ENDIAN, bsds define
55
+ *          _BIG_ENDIAN, _LITTLE_ENDIAN, BIG_ENDIAN, LITTLE_ENDIAN)
56
+ *
57
+ */
58
+
59
+
60
+#ifndef _endianness_h
61
+#define _endianness_h
62
+
63
+/* use bsd includes: they work everywhere */
64
+#include <sys/types.h>
65
+#include <sys/param.h>
66
+
67
+
68
+
69
+extern int _endian_test_int;
70
+
71
+/* returns 1 for little endian, 0 for big endian */
72
+#define endian_test()		(*(char*)&_endian_test_int==1)
73
+#define is_big_endian()		(!endian_test())
74
+#define is_little_endian()	endian_test()
75
+
76
+
77
+extern int endianness_sanity_check();
78
+
79
+/* detect compile time endianess */
80
+#if defined __BYTE_ORDER && defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
81
+/* linux */
82
+#if __BYTE_ORDER == __LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
83
+	#define __IS_LITTLE_ENDIAN 0x01020304
84
+#endif
85
+#if __BYTE_ORDER == __BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
86
+	#define __IS_BIG_ENDIAN 0x01020304
87
+#endif
88
+#elif defined _BYTE_ORDER && defined _LITTLE_ENDIAN && defined _BIG_ENDIAN
89
+/* bsd */
90
+#if _BYTE_ORDER == _LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
91
+	#define __IS_LITTLE_ENDIAN 0x01020304
92
+#endif
93
+#if _BYTE_ORDER == _BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
94
+	#define __IS_BIG_ENDIAN 0x01020304
95
+#endif
96
+#elif defined BYTE_ORDER && defined LITTLE_ENDIAN && defined BIG_ENDIAN
97
+/* bsd old/deprecated */
98
+#if BYTE_ORDER == LITTLE_ENDIAN && ! defined __IS_LITTLE_ENDIAN
99
+	#define __IS_LITTLE_ENDIAN 0x01020304
100
+#endif
101
+#if BYTE_ORDER == BIG_ENDIAN && ! defined __IS_BIG_ENDIAN
102
+	#define __IS_BIG_ENDIAN 0x01020304
103
+#endif
104
+#elif !(defined _LITTLE_ENDIAN && defined _BIG_ENDIAN) && \
105
+		(defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
106
+/* OSes that don't define BYTE_ORDER (sanity check above makes sure
107
+ *   little & big endian are not defined in the same time )*/
108
+/* solaris */
109
+#if defined _LITTLE_ENDIAN && !defined __IS_LITLE_ENDIAN
110
+	#define __IS_LITTLE_ENDIAN 0x01020304
111
+#endif
112
+#if defined _BIG_ENDIAN && !defined __IS_BIG_ENDIAN
113
+	#define __IS_BIG_ENDIAN 0x04030201
114
+#endif
115
+#elif !(defined LITTLE_ENDIAN && defined BIG_ENDIAN) && \
116
+		(defined LITTLE_ENDIAN || defined BIG_ENDIAN)
117
+/* OSes that don't define BYTE_ORDER (sanity check above makes sure
118
+ *   little & big endian are not defined in the same time )*/
119
+#if defined LITTLE_ENDIAN && !defined __IS_LITLE_ENDIAN
120
+	#define __IS_LITTLE_ENDIAN 0x01020304
121
+#endif
122
+#if defined BIG_ENDIAN && !defined __IS_BIG_ENDIAN
123
+	#define __IS_BIG_ENDIAN 0x04030201
124
+#endif
125
+
126
+#else
127
+#error could not detect endianess
128
+#endif
129
+
130
+#if !defined __IS_LITTLE_ENDIAN && !defined __IS_BIG_ENDIAN
131
+#error BUG: could not detect endianess
132
+#endif
133
+
134
+#if defined __IS_LITTLE_ENDIAN && defined __IS_BIG_ENDIAN
135
+#error BUG: both little & big endian detected in the same time
136
+#endif
137
+
138
+
139
+#endif /* _endianness_h */
140
+