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,174 +0,0 @@
1
-/*
2
- * Copyright (C) 2001-2003 FhG Fokus
3
- *
4
- * This file is part of Kamailio, a free SIP server.
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
-/**
20
- * \file
21
- * \brief Simple & fast malloc library
22
- * \ingroup mem
23
- */
24
-
25
-#if defined(Q_MALLOC)
26
-
27
-#if !defined(q_malloc_h)
28
-#define q_malloc_h
29
-
30
-#include "meminfo.h"
31
-
32
-#ifdef DBG_SR_MEMORY
33
-#define DBG_QM_MALLOC
34
-#endif
35
-
36
-/* defs*/
37
-#ifdef DBG_QM_MALLOC
38
-#if defined(__CPU_sparc64) || defined(__CPU_sparc)
39
-/* tricky, on sun in 32 bits mode long long must be 64 bits aligned
40
- * but long can be 32 bits aligned => malloc should return long long
41
- * aligned memory */
42
-	#define ROUNDTO		sizeof(long long)
43
-#else
44
-	#define ROUNDTO		sizeof(void*) /* minimum possible ROUNDTO ->heavy 
45
-										 debugging*/
46
-#endif 
47
-#else /* DBG_QM_MALLOC */
48
-	#define ROUNDTO		16UL /* size we round to, must be = 2^n  and also
49
-							 sizeof(qm_frag)+sizeof(qm_frag_end)
50
-							 must be multiple of ROUNDTO!
51
-						   */
52
-#endif
53
-#define MIN_FRAG_SIZE	ROUNDTO
54
-
55
-
56
-
57
-#define QM_MALLOC_OPTIMIZE_FACTOR 14UL /*used below */
58
-#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
59
-								/* size to optimize for,
60
-									(most allocs <= this size),
61
-									must be 2^k */
62
-
63
-#define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
64
-		(sizeof(long)*8-QM_MALLOC_OPTIMIZE_FACTOR)+1))
65
-
66
-/* hash structure:
67
- * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
68
- *                            ROUNDTO from bucket to bucket
69
- * +1 .... end -  size = 2^k, big buckets */
70
-
71
-struct qm_frag{
72
-	unsigned long size;
73
-	union{
74
-		struct qm_frag* nxt_free;
75
-		long is_free;
76
-	}u;
77
-#ifdef DBG_QM_MALLOC
78
-	const char* file;
79
-	const char* func;
80
-	const char* mname;
81
-	unsigned long line;
82
-	unsigned long check;
83
-#endif
84
-};
85
-
86
-struct qm_frag_end{
87
-#ifdef DBG_QM_MALLOC
88
-	unsigned long check1;
89
-	unsigned long check2;
90
-	unsigned long reserved1;
91
-	unsigned long reserved2;
92
-#endif
93
-	unsigned long size;
94
-	struct qm_frag* prev_free;
95
-};
96
-
97
-
98
-
99
-struct qm_frag_lnk{
100
-	struct qm_frag head;
101
-	struct qm_frag_end tail;
102
-	unsigned long no;
103
-};
104
-
105
-
106
-/**
107
- * \brief Block of memory for Q_MALLOC memory manager
108
- * \see mem_info
109
- */
110
-
111
-struct qm_block{
112
-	int type; /* type of memory */
113
-	unsigned long size; /* total size */
114
-	unsigned long used; /* alloc'ed size*/
115
-	unsigned long real_used; /* used+malloc overhead*/
116
-	unsigned long max_real_used;
117
-	unsigned long ffrags;
118
-	
119
-	struct qm_frag* first_frag;
120
-	struct qm_frag_end* last_frag_end;
121
-	
122
-	struct qm_frag_lnk free_hash[QM_HASH_SIZE];
123
-	/*struct qm_frag_end free_lst_end;*/
124
-};
125
-
126
-
127
-
128
-struct qm_block* qm_malloc_init(char* address, unsigned long size, int type);
129
-
130
-#ifdef DBG_QM_MALLOC
131
-void* qm_malloc(void*, size_t size, const char* file,
132
-					const char* func, unsigned int line, const char* mname);
133
-#else
134
-void* qm_malloc(void*, size_t size);
135
-#endif
136
-
137
-#ifdef DBG_QM_MALLOC
138
-void  qm_free(void*, void* p, const char* file, const char* func,
139
-				unsigned int line, const char* mname);
140
-#else
141
-void  qm_free(void*, void* p);
142
-#endif
143
-#ifdef DBG_QM_MALLOC
144
-void* qm_realloc(void*, void* p, size_t size,
145
-					const char* file, const char* func, unsigned int line, const char *mname);
146
-#else
147
-void* qm_realloc(void*, void* p, size_t size);
148
-#endif
149
-
150
-void  qm_check(struct qm_block*);
151
-
152
-void  qm_status(void*);
153
-void  qm_info(void*, struct mem_info*);
154
-
155
-unsigned long qm_available(void* qm);
156
-
157
-void qm_sums(void* qm);
158
-void qm_mod_get_stats(void *qm, void **qm_root);
159
-void qm_mod_free_stats(void *root);
160
-
161
-typedef struct _mem_counter{
162
-	const char *file;
163
-	const char *func;
164
-	const char *mname;
165
-	unsigned long line;
166
-
167
-	unsigned long size;
168
-	int count;
169
-
170
-	struct _mem_counter *next;
171
-} mem_counter;
172
-
173
-#endif
174
-#endif
Browse code

core: mem - use size_t for qm memory management functions

Daniel-Constantin Mierla authored on 08/06/2016 08:03:50
Showing 1 changed files
... ...
@@ -128,10 +128,10 @@ struct qm_block{
128 128
 struct qm_block* qm_malloc_init(char* address, unsigned long size, int type);
129 129
 
130 130
 #ifdef DBG_QM_MALLOC
131
-void* qm_malloc(void*, unsigned long size, const char* file,
131
+void* qm_malloc(void*, size_t size, const char* file,
132 132
 					const char* func, unsigned int line, const char* mname);
133 133
 #else
134
-void* qm_malloc(void*, unsigned long size);
134
+void* qm_malloc(void*, size_t size);
135 135
 #endif
136 136
 
137 137
 #ifdef DBG_QM_MALLOC
... ...
@@ -141,10 +141,10 @@ void  qm_free(void*, void* p, const char* file, const char* func,
141 141
 void  qm_free(void*, void* p);
142 142
 #endif
143 143
 #ifdef DBG_QM_MALLOC
144
-void* qm_realloc(void*, void* p, unsigned long size,
144
+void* qm_realloc(void*, void* p, size_t size,
145 145
 					const char* file, const char* func, unsigned int line, const char *mname);
146 146
 #else
147
-void* qm_realloc(void*, void* p, unsigned long size);
147
+void* qm_realloc(void*, void* p, size_t size);
148 148
 #endif
149 149
 
150 150
 void  qm_check(struct qm_block*);
Browse code

mem: q_malloc extended for per module memory stats

Stefan Mititelu authored on 02/11/2015 12:48:54 • Daniel-Constantin Mierla committed on 02/11/2015 12:48:54
Showing 1 changed files
... ...
@@ -77,6 +77,7 @@ struct qm_frag{
77 77
 #ifdef DBG_QM_MALLOC
78 78
 	const char* file;
79 79
 	const char* func;
80
+	const char* mname;
80 81
 	unsigned long line;
81 82
 	unsigned long check;
82 83
 #endif
... ...
@@ -128,20 +129,20 @@ struct qm_block* qm_malloc_init(char* address, unsigned long size, int type);
128 129
 
129 130
 #ifdef DBG_QM_MALLOC
130 131
 void* qm_malloc(void*, unsigned long size, const char* file,
131
-					const char* func, unsigned int line);
132
+					const char* func, unsigned int line, const char* mname);
132 133
 #else
133 134
 void* qm_malloc(void*, unsigned long size);
134 135
 #endif
135 136
 
136 137
 #ifdef DBG_QM_MALLOC
137
-void  qm_free(void*, void* p, const char* file, const char* func, 
138
-				unsigned int line);
138
+void  qm_free(void*, void* p, const char* file, const char* func,
139
+				unsigned int line, const char* mname);
139 140
 #else
140 141
 void  qm_free(void*, void* p);
141 142
 #endif
142 143
 #ifdef DBG_QM_MALLOC
143 144
 void* qm_realloc(void*, void* p, unsigned long size,
144
-					const char* file, const char* func, unsigned int line);
145
+					const char* file, const char* func, unsigned int line, const char *mname);
145 146
 #else
146 147
 void* qm_realloc(void*, void* p, unsigned long size);
147 148
 #endif
... ...
@@ -154,6 +155,20 @@ void  qm_info(void*, struct mem_info*);
154 155
 unsigned long qm_available(void* qm);
155 156
 
156 157
 void qm_sums(void* qm);
158
+void qm_mod_get_stats(void *qm, void **qm_root);
159
+void qm_mod_free_stats(void *root);
160
+
161
+typedef struct _mem_counter{
162
+	const char *file;
163
+	const char *func;
164
+	const char *mname;
165
+	unsigned long line;
166
+
167
+	unsigned long size;
168
+	int count;
169
+
170
+	struct _mem_counter *next;
171
+} mem_counter;
157 172
 
158 173
 #endif
159 174
 #endif
Browse code

mem: q_malloc updated to implement new pkg/shm management api

Daniel-Constantin Mierla authored on 14/09/2015 07:25:23
Showing 1 changed files
... ...
@@ -22,11 +22,17 @@
22 22
  * \ingroup mem
23 23
  */
24 24
 
25
-#if !defined(q_malloc_h) && !defined(F_MALLOC) && !defined(TLSF_MALLOC)
25
+#if defined(Q_MALLOC)
26
+
27
+#if !defined(q_malloc_h)
26 28
 #define q_malloc_h
27 29
 
28 30
 #include "meminfo.h"
29 31
 
32
+#ifdef DBG_SR_MEMORY
33
+#define DBG_QM_MALLOC
34
+#endif
35
+
30 36
 /* defs*/
31 37
 #ifdef DBG_QM_MALLOC
32 38
 #if defined(__CPU_sparc64) || defined(__CPU_sparc)
... ...
@@ -121,35 +127,33 @@ struct qm_block{
121 127
 struct qm_block* qm_malloc_init(char* address, unsigned long size, int type);
122 128
 
123 129
 #ifdef DBG_QM_MALLOC
124
-void* qm_malloc(struct qm_block*, unsigned long size, const char* file,
130
+void* qm_malloc(void*, unsigned long size, const char* file,
125 131
 					const char* func, unsigned int line);
126 132
 #else
127
-void* qm_malloc(struct qm_block*, unsigned long size);
133
+void* qm_malloc(void*, unsigned long size);
128 134
 #endif
129 135
 
130 136
 #ifdef DBG_QM_MALLOC
131
-void  qm_free(struct qm_block*, void* p, const char* file, const char* func, 
137
+void  qm_free(void*, void* p, const char* file, const char* func, 
132 138
 				unsigned int line);
133 139
 #else
134
-void  qm_free(struct qm_block*, void* p);
140
+void  qm_free(void*, void* p);
135 141
 #endif
136 142
 #ifdef DBG_QM_MALLOC
137
-void* qm_realloc(struct qm_block*, void* p, unsigned long size,
143
+void* qm_realloc(void*, void* p, unsigned long size,
138 144
 					const char* file, const char* func, unsigned int line);
139 145
 #else
140
-void* qm_realloc(struct qm_block*, void* p, unsigned long size);
146
+void* qm_realloc(void*, void* p, unsigned long size);
141 147
 #endif
142 148
 
143
-void  qm_status(struct qm_block*);
144 149
 void  qm_check(struct qm_block*);
145
-void  qm_info(struct qm_block*, struct mem_info*);
146 150
 
147
-unsigned long qm_available(struct qm_block* qm);
151
+void  qm_status(void*);
152
+void  qm_info(void*, struct mem_info*);
148 153
 
149
-#ifdef DBG_QM_MALLOC
150
-void qm_sums(struct qm_block* qm);
151
-#else
152
-#define qm_sums(v) do{}while(0)
153
-#endif /*DBQ_QM_MALLOC */
154
+unsigned long qm_available(void* qm);
155
+
156
+void qm_sums(void* qm);
154 157
 
155 158
 #endif
159
+#endif
Browse code

mem: TLSF memory summary and sums implementation

TLSF now has a debug mode, that will dump every memory block when xxx_status()
is called, and a summary of still allocated blocks when xxx_sums() is called.

configure build with

make MEMDBG=1 MEMMNG=2 cfg

to enable maximum debuging informations (source location of mallocs and frees)

Camille Oudot authored on 19/05/2015 17:58:57
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
  * \ingroup mem
23 23
  */
24 24
 
25
-#if !defined(q_malloc_h) && !defined(F_MALLOC)
25
+#if !defined(q_malloc_h) && !defined(F_MALLOC) && !defined(TLSF_MALLOC)
26 26
 #define q_malloc_h
27 27
 
28 28
 #include "meminfo.h"
Browse code

mem Remove SVN ID, remove history

Olle E. Johansson authored on 25/02/2015 08:12:38
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * Copyright (C) 2001-2003 FhG Fokus
3 3
  *
4
- * This file is part of sip-router, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
5 5
  *
6 6
  * Permission to use, copy, modify, and distribute this software for any
7 7
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -16,16 +16,6 @@
16 16
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
  */
18 18
 
19
-/*
20
- * History:
21
- * --------
22
- *  2003-05-21  on sparc64 roundto 8 even in debugging mode (so malloc'ed
23
- *               long longs will be 64 bit aligned) (andrei)
24
- *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
25
- *               for the future de-fragmentation support (andrei)
26
- *  2004-11-10  support for > 4Gb mem. (switched to long) (andrei)
27
- */
28
-
29 19
 /**
30 20
  * \file
31 21
  * \brief Simple & fast malloc library
Browse code

core/mem: q_malloc updates to set pool type and pkg stats refactoring

- total free fragments are kept in memory root block to avoid computing
them by walking the hash table
- use single event callback to update per process pkg stats, executed at
the end of malloc, free or realloc opperations

Daniel-Constantin Mierla authored on 03/05/2014 18:07:41
Showing 1 changed files
... ...
@@ -112,10 +112,12 @@ struct qm_frag_lnk{
112 112
  */
113 113
 
114 114
 struct qm_block{
115
+	int type; /* type of memory */
115 116
 	unsigned long size; /* total size */
116 117
 	unsigned long used; /* alloc'ed size*/
117 118
 	unsigned long real_used; /* used+malloc overhead*/
118 119
 	unsigned long max_real_used;
120
+	unsigned long ffrags;
119 121
 	
120 122
 	struct qm_frag* first_frag;
121 123
 	struct qm_frag_end* last_frag_end;
... ...
@@ -126,7 +128,7 @@ struct qm_block{
126 128
 
127 129
 
128 130
 
129
-struct qm_block* qm_malloc_init(char* address, unsigned long size);
131
+struct qm_block* qm_malloc_init(char* address, unsigned long size, int type);
130 132
 
131 133
 #ifdef DBG_QM_MALLOC
132 134
 void* qm_malloc(struct qm_block*, unsigned long size, const char* file,
Browse code

mem: initial doxygen documentation for MM, small whitespace changes

Henning Westerholt authored on 13/07/2011 22:11:48
Showing 1 changed files
... ...
@@ -1,7 +1,4 @@
1
-/* $Id$
2
- *
3
- * simple & fast malloc library
4
- *
1
+/*
5 2
  * Copyright (C) 2001-2003 FhG Fokus
6 3
  *
7 4
  * This file is part of sip-router, a free SIP server.
... ...
@@ -18,6 +15,7 @@
18 15
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 16
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 17
  */
18
+
21 19
 /*
22 20
  * History:
23 21
  * --------
... ...
@@ -28,6 +26,11 @@
28 26
  *  2004-11-10  support for > 4Gb mem. (switched to long) (andrei)
29 27
  */
30 28
 
29
+/**
30
+ * \file
31
+ * \brief Simple & fast malloc library
32
+ * \ingroup mem
33
+ */
31 34
 
32 35
 #if !defined(q_malloc_h) && !defined(F_MALLOC)
33 36
 #define q_malloc_h
... ...
@@ -103,6 +106,11 @@ struct qm_frag_lnk{
103 106
 };
104 107
 
105 108
 
109
+/**
110
+ * \brief Block of memory for Q_MALLOC memory manager
111
+ * \see mem_info
112
+ */
113
+
106 114
 struct qm_block{
107 115
 	unsigned long size; /* total size */
108 116
 	unsigned long used; /* alloc'ed size*/
Browse code

core: mem dbg options updates + cleanups

- memlog and memdbg can now be changed at runtime
- double define warning fix for fm_malloc (when compiled with -DF_MALLOC)
- nicer qm_status() & qm_sums() output
- BSD licence for mem/*

Andrei Pelinescu-Onciul authored on 29/09/2009 13:25:50
Showing 1 changed files
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
Browse code

core: remove VQ_MALLOC memory manager

attached patch removes the VQ_MALLOC memory manager from the
sip-router core. As discussed some time ago, this memory manager
doesn't provide a realloc implementation, and is thus not really
usable for the modules, as some of them needs this. We removed
this in kamailio in the last year, so far nobody missed it.

Signed-off-by: Andrei Pelinescu-Onciul <andrei@iptel.org>

Henning Westerholt authored on 17/03/2009 12:24:42 • Andrei Pelinescu-Onciul committed on 29/09/2009 17:03:41
Showing 1 changed files
... ...
@@ -36,7 +36,7 @@
36 36
  */
37 37
 
38 38
 
39
-#if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC)
39
+#if !defined(q_malloc_h) && !defined(F_MALLOC)
40 40
 #define q_malloc_h
41 41
 
42 42
 #include "meminfo.h"
Browse code

mem: summarize in-use memory on exit

Additional qm_sums and fm_sums as extension to qm_status/fm_status, with
summarized values per allocation source.
Slightly modified SER-224 patch version (no locking, sr changes --andrei).

Closes SER-224.

Signed-off-by: Andrei Pelinescu-Onciul <andrei@iptel.org>

Dragos Vingarzan authored on 28/09/2009 20:01:17 • Andrei Pelinescu-Onciul committed on 29/09/2009 17:03:40
Showing 1 changed files
... ...
@@ -153,4 +153,10 @@ void  qm_info(struct qm_block*, struct mem_info*);
153 153
 
154 154
 unsigned long qm_available(struct qm_block* qm);
155 155
 
156
+#ifdef DBG_QM_MALLOC
157
+void qm_sums(struct qm_block* qm);
158
+#else
159
+#define qm_sums(v) do{}while(0)
160
+#endif /*DBQ_QM_MALLOC */
161
+
156 162
 #endif
Browse code

added function qm_check\(\) which checks integrity of pkg mem. If you have a problem with memory you can include qm_check() into lovely places in your code and at these checkpoints integrity pf pkg memory will be checked.

Libor Chocholaty authored on 14/07/2008 13:37:42
Showing 1 changed files
... ...
@@ -148,6 +148,7 @@ void* qm_realloc(struct qm_block*, void* p, unsigned long size);
148 148
 #endif
149 149
 
150 150
 void  qm_status(struct qm_block*);
151
+void  qm_check(struct qm_block*);
151 152
 void  qm_info(struct qm_block*, struct mem_info*);
152 153
 
153 154
 unsigned long qm_available(struct qm_block* qm);
Browse code

- added shm_available/pkg_available/{qm,fm}_available: return the ammount of free memory

Andrei Pelinescu-Onciul authored on 23/02/2007 23:20:51
Showing 1 changed files
... ...
@@ -150,5 +150,6 @@ void* qm_realloc(struct qm_block*, void* p, unsigned long size);
150 150
 void  qm_status(struct qm_block*);
151 151
 void  qm_info(struct qm_block*, struct mem_info*);
152 152
 
153
+unsigned long qm_available(struct qm_block* qm);
153 154
 
154 155
 #endif
Browse code

- solaris fixes: - renamed struct meminfo to mem_info due to name conflicts, fixed sc $$(atempts+1) (thanks go to Josip Gracin) - proper ISA ARCH detection on solaris (uname -p) - cosmetics: io_wait log log msg. removed

Andrei Pelinescu-Onciul authored on 25/07/2005 14:41:20
Showing 1 changed files
... ...
@@ -148,7 +148,7 @@ void* qm_realloc(struct qm_block*, void* p, unsigned long size);
148 148
 #endif
149 149
 
150 150
 void  qm_status(struct qm_block*);
151
-void  qm_info(struct qm_block*, struct meminfo*);
151
+void  qm_info(struct qm_block*, struct mem_info*);
152 152
 
153 153
 
154 154
 #endif
Browse code

- re-enabled locking in shm_status() - added fifo meminfo commands: serctl fifo meminfo total:33340380 free:33112744 used:227636 max used:227636 fragments:1

(where used = allocated shm mem + overhead)

Andrei Pelinescu-Onciul authored on 02/03/2005 11:45:12
Showing 1 changed files
... ...
@@ -39,7 +39,7 @@
39 39
 #if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC)
40 40
 #define q_malloc_h
41 41
 
42
-
42
+#include "meminfo.h"
43 43
 
44 44
 /* defs*/
45 45
 #ifdef DBG_QM_MALLOC
... ...
@@ -148,6 +148,7 @@ void* qm_realloc(struct qm_block*, void* p, unsigned long size);
148 148
 #endif
149 149
 
150 150
 void  qm_status(struct qm_block*);
151
+void  qm_info(struct qm_block*, struct meminfo*);
151 152
 
152 153
 
153 154
 #endif
Browse code

- various pre-release updates - use_domain set to 0 by default in all the modules - experimental sparc32 non-SMP support (thanks to Michael Grigoni)

Andrei Pelinescu-Onciul authored on 16/12/2004 17:39:46
Showing 1 changed files
... ...
@@ -43,7 +43,7 @@
43 43
 
44 44
 /* defs*/
45 45
 #ifdef DBG_QM_MALLOC
46
-#ifdef __CPU_sparc64
46
+#if defined(__CPU_sparc64) || defined(__CPU_sparc)
47 47
 /* tricky, on sun in 32 bits mode long long must be 64 bits aligned
48 48
  * but long can be 32 bits aligned => malloc should return long long
49 49
  * aligned memory */
Browse code

- warnings fixed for gcc-3.4 - older solaris support (5.6)

Andrei Pelinescu-Onciul authored on 08/12/2004 19:06:12
Showing 1 changed files
... ...
@@ -83,8 +83,8 @@ struct qm_frag{
83 83
 		long is_free;
84 84
 	}u;
85 85
 #ifdef DBG_QM_MALLOC
86
-	char* file;
87
-	char* func;
86
+	const char* file;
87
+	const char* func;
88 88
 	unsigned long line;
89 89
 	unsigned long check;
90 90
 #endif
... ...
@@ -128,21 +128,21 @@ struct qm_block{
128 128
 struct qm_block* qm_malloc_init(char* address, unsigned long size);
129 129
 
130 130
 #ifdef DBG_QM_MALLOC
131
-void* qm_malloc(struct qm_block*, unsigned long size, char* file, char* func, 
132
-					unsigned int line);
131
+void* qm_malloc(struct qm_block*, unsigned long size, const char* file,
132
+					const char* func, unsigned int line);
133 133
 #else
134 134
 void* qm_malloc(struct qm_block*, unsigned long size);
135 135
 #endif
136 136
 
137 137
 #ifdef DBG_QM_MALLOC
138
-void  qm_free(struct qm_block*, void* p, char* file, char* func, 
138
+void  qm_free(struct qm_block*, void* p, const char* file, const char* func, 
139 139
 				unsigned int line);
140 140
 #else
141 141
 void  qm_free(struct qm_block*, void* p);
142 142
 #endif
143 143
 #ifdef DBG_QM_MALLOC
144 144
 void* qm_realloc(struct qm_block*, void* p, unsigned long size,
145
-				char* file, char* func, unsigned int line);
145
+					const char* file, const char* func, unsigned int line);
146 146
 #else
147 147
 void* qm_realloc(struct qm_block*, void* p, unsigned long size);
148 148
 #endif
Browse code

- malloc debugging on by default (warning: lots of debugging info) - malloc hash size adjusted - avpops: 64 bit warnings fixed - tm: log messages

Andrei Pelinescu-Onciul authored on 17/11/2004 23:26:03
Showing 1 changed files
... ...
@@ -62,7 +62,7 @@
62 62
 
63 63
 
64 64
 
65
-#define QM_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
65
+#define QM_MALLOC_OPTIMIZE_FACTOR 14UL /*used below */
66 66
 #define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
67 67
 								/* size to optimize for,
68 68
 									(most allocs <= this size),
Browse code

- more than 4Gb memory support (ser -m 5192 will work and use 5Gb of memory)

Andrei Pelinescu-Onciul authored on 10/11/2004 21:51:24
Showing 1 changed files
... ...
@@ -32,6 +32,7 @@
32 32
  *               long longs will be 64 bit aligned) (andrei)
33 33
  *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
34 34
  *               for the future de-fragmentation support (andrei)
35
+ *  2004-11-10  support for > 4Gb mem. (switched to long) (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -52,7 +53,7 @@
52 53
 										 debugging*/
53 54
 #endif 
54 55
 #else /* DBG_QM_MALLOC */
55
-	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
56
+	#define ROUNDTO		16UL /* size we round to, must be = 2^n  and also
56 57
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
57 58
 							 must be multiple of ROUNDTO!
58 59
 						   */
... ...
@@ -61,8 +62,8 @@
61 62
 
62 63
 
63 64
 
64
-#define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
65
-#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
65
+#define QM_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
66
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
66 67
 								/* size to optimize for,
67 68
 									(most allocs <= this size),
68 69
 									must be 2^k */
... ...
@@ -124,13 +125,13 @@ struct qm_block{
124 125
 
125 126
 
126 127
 
127
-struct qm_block* qm_malloc_init(char* address, unsigned int size);
128
+struct qm_block* qm_malloc_init(char* address, unsigned long size);
128 129
 
129 130
 #ifdef DBG_QM_MALLOC
130
-void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
131
+void* qm_malloc(struct qm_block*, unsigned long size, char* file, char* func, 
131 132
 					unsigned int line);
132 133
 #else
133
-void* qm_malloc(struct qm_block*, unsigned int size);
134
+void* qm_malloc(struct qm_block*, unsigned long size);
134 135
 #endif
135 136
 
136 137
 #ifdef DBG_QM_MALLOC
... ...
@@ -140,10 +141,10 @@ void  qm_free(struct qm_block*, void* p, char* file, char* func,
140 141
 void  qm_free(struct qm_block*, void* p);
141 142
 #endif
142 143
 #ifdef DBG_QM_MALLOC
143
-void* qm_realloc(struct qm_block*, void* p, unsigned int size,
144
+void* qm_realloc(struct qm_block*, void* p, unsigned long size,
144 145
 				char* file, char* func, unsigned int line);
145 146
 #else
146
-void* qm_realloc(struct qm_block*, void* p, unsigned int size);
147
+void* qm_realloc(struct qm_block*, void* p, unsigned long size);
147 148
 #endif
148 149
 
149 150
 void  qm_status(struct qm_block*);
Browse code

-x86_64 experimental support -various 64 bit warning fixes

Andrei Pelinescu-Onciul authored on 28/09/2004 18:10:08
Showing 1 changed files
... ...
@@ -68,7 +68,7 @@
68 68
 									must be 2^k */
69 69
 
70 70
 #define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
71
-		(sizeof(long)-QM_MALLOC_OPTIMIZE_FACTOR)+1))
71
+		(sizeof(long)*8-QM_MALLOC_OPTIMIZE_FACTOR)+1))
72 72
 
73 73
 /* hash structure:
74 74
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
Browse code

- Spelling checked - READMEs updated

Jan Janak authored on 24/08/2004 08:58:23
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
  *
3 3
  * simple & fast malloc library
4 4
  *
5
- * Copyright (C) 2001-2003 Fhg Fokus
5
+ * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7 7
  * This file is part of ser, a free SIP server.
8 8
  *
... ...
@@ -54,7 +54,7 @@
54 54
 #else /* DBG_QM_MALLOC */
55 55
 	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
56 56
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
57
-							 must be mutliple of ROUNDTO!
57
+							 must be multiple of ROUNDTO!
58 58
 						   */
59 59
 #endif
60 60
 #define MIN_FRAG_SIZE	ROUNDTO
Browse code

- malloc changes: fragment avoidance, bookkeeping, hooks for future full mem. defragmenter

Andrei Pelinescu-Onciul authored on 19/07/2004 13:45:50
Showing 1 changed files
... ...
@@ -30,6 +30,8 @@
30 30
  * --------
31 31
  *  2003-05-21  on sparc64 roundto 8 even in debugging mode (so malloc'ed
32 32
  *               long longs will be 64 bit aligned) (andrei)
33
+ *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
34
+ *               for the future de-fragmentation support (andrei)
33 35
  */
34 36
 
35 37
 
... ...
@@ -62,11 +64,11 @@
62 64
 #define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
63 65
 #define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
64 66
 								/* size to optimize for,
65
-									(most allocs < this size),
67
+									(most allocs <= this size),
66 68
 									must be 2^k */
67 69
 
68 70
 #define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
69
-		(32-QM_MALLOC_OPTIMIZE_FACTOR)+1))
71
+		(sizeof(long)-QM_MALLOC_OPTIMIZE_FACTOR)+1))
70 72
 
71 73
 /* hash structure:
72 74
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
... ...
@@ -100,9 +102,10 @@ struct qm_frag_end{
100 102
 
101 103
 
102 104
 
103
-struct qm_frag_full{
105
+struct qm_frag_lnk{
104 106
 	struct qm_frag head;
105 107
 	struct qm_frag_end tail;
108
+	unsigned long no;
106 109
 };
107 110
 
108 111
 
... ...
@@ -115,7 +118,7 @@ struct qm_block{
115 118
 	struct qm_frag* first_frag;
116 119
 	struct qm_frag_end* last_frag_end;
117 120
 	
118
-	struct qm_frag_full free_hash[QM_HASH_SIZE];
121
+	struct qm_frag_lnk free_hash[QM_HASH_SIZE];
119 122
 	/*struct qm_frag_end free_lst_end;*/
120 123
 };
121 124
 
Browse code

- preliminary tls support - added qm_realloc/pkg_realloc/shm_realloc (needed by libssl)

Andrei Pelinescu-Onciul authored on 30/06/2003 10:04:02
Showing 1 changed files
... ...
@@ -136,6 +136,12 @@ void  qm_free(struct qm_block*, void* p, char* file, char* func,
136 136
 #else
137 137
 void  qm_free(struct qm_block*, void* p);
138 138
 #endif
139
+#ifdef DBG_QM_MALLOC
140
+void* qm_realloc(struct qm_block*, void* p, unsigned int size,
141
+				char* file, char* func, unsigned int line);
142
+#else
143
+void* qm_realloc(struct qm_block*, void* p, unsigned int size);
144
+#endif
139 145
 
140 146
 void  qm_status(struct qm_block*);
141 147
 
Browse code

- hopefully fixed the sun mysql problems (mallocs are now long long aligned for sparc64 and not only long, even in debugging mode)

Andrei Pelinescu-Onciul authored on 21/05/2003 16:42:34
Showing 1 changed files
... ...
@@ -25,6 +25,12 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+/*
29
+ * History:
30
+ * --------
31
+ *  2003-05-21  on sparc64 roundto 8 even in debugging mode (so malloc'ed
32
+ *               long longs will be 64 bit aligned) (andrei)
33
+ */
28 34
 
29 35
 
30 36
 #if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC)
... ...
@@ -34,9 +40,16 @@
34 40
 
35 41
 /* defs*/
36 42
 #ifdef DBG_QM_MALLOC
43
+#ifdef __CPU_sparc64
44
+/* tricky, on sun in 32 bits mode long long must be 64 bits aligned
45
+ * but long can be 32 bits aligned => malloc should return long long
46
+ * aligned memory */
47
+	#define ROUNDTO		sizeof(long long)
48
+#else
37 49
 	#define ROUNDTO		sizeof(void*) /* minimum possible ROUNDTO ->heavy 
38 50
 										 debugging*/
39
-#else
51
+#endif 
52
+#else /* DBG_QM_MALLOC */
40 53
 	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
41 54
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
42 55
 							 must be mutliple of ROUNDTO!
Browse code

-changed DEBUG ROUNDTO to sizeof(void*) (4 on 32 bits archs & 8 on 64bits)

Andrei Pelinescu-Onciul authored on 24/02/2003 16:47:23
Showing 1 changed files
... ...
@@ -34,7 +34,8 @@
34 34
 
35 35
 /* defs*/
36 36
 #ifdef DBG_QM_MALLOC
37
-	#define ROUNDTO		 8 /* minimum possible ROUNDTO ->heavy debugging*/
37
+	#define ROUNDTO		sizeof(void*) /* minimum possible ROUNDTO ->heavy 
38
+										 debugging*/
38 39
 #else
39 40
 	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
40 41
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
Browse code

- fixed all the warnings in core (now it compiles cleanly on linux/i386, solaris/sparc64, netbsd/sparc64, freebsd/i386, openbsd/i386).

Andrei Pelinescu-Onciul authored on 26/11/2002 15:29:51
Showing 1 changed files
... ...
@@ -46,13 +46,13 @@
46 46
 
47 47
 
48 48
 #define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
49
-#define QM_MALLOC_OPTIMIZE  (1<<QM_MALLOC_OPTIMIZE_FACTOR)
49
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
50 50
 								/* size to optimize for,
51 51
 									(most allocs < this size),
52 52
 									must be 2^k */
53 53
 
54
-#define QM_HASH_SIZE (QM_MALLOC_OPTIMIZE/ROUNDTO + \
55
-		(32-QM_MALLOC_OPTIMIZE_FACTOR)+1)
54
+#define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
55
+		(32-QM_MALLOC_OPTIMIZE_FACTOR)+1))
56 56
 
57 57
 /* hash structure:
58 58
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
Browse code

- netbsd fixes - 64 bit mini-cleanup

Andrei Pelinescu-Onciul authored on 25/11/2002 20:29:44
Showing 1 changed files
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 /* defs*/
36 36
 #ifdef DBG_QM_MALLOC
37
-	#define ROUNDTO		 4 /* minimum possible ROUNDTO ->heavy debugging*/
37
+	#define ROUNDTO		 8 /* minimum possible ROUNDTO ->heavy debugging*/
38 38
 #else
39 39
 	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
40 40
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
... ...
@@ -60,27 +60,27 @@
60 60
  * +1 .... end -  size = 2^k, big buckets */
61 61
 
62 62
 struct qm_frag{
63
-	unsigned int size;
63
+	unsigned long size;
64 64
 	union{
65 65
 		struct qm_frag* nxt_free;
66
-		int is_free;
66
+		long is_free;
67 67
 	}u;
68 68
 #ifdef DBG_QM_MALLOC
69 69
 	char* file;
70 70
 	char* func;
71
-	unsigned int line;
72
-	unsigned int check;
71
+	unsigned long line;
72
+	unsigned long check;
73 73
 #endif
74 74
 };
75 75
 
76 76
 struct qm_frag_end{
77 77
 #ifdef DBG_QM_MALLOC
78
-	unsigned int check1;
79
-	unsigned int check2;
80
-	unsigned int reserved1;
81
-	unsigned int reserved2;
78
+	unsigned long check1;
79
+	unsigned long check2;
80
+	unsigned long reserved1;
81
+	unsigned long reserved2;
82 82
 #endif
83
-	unsigned int size;
83
+	unsigned long size;
84 84
 	struct qm_frag* prev_free;
85 85
 };
86 86
 
... ...
@@ -93,10 +93,10 @@ struct qm_frag_full{
93 93
 
94 94
 
95 95
 struct qm_block{
96
-	unsigned int size; /* total size */
97
-	unsigned int used; /* alloc'ed size*/
98
-	unsigned int real_used; /* used+malloc overhead*/
99
-	unsigned int max_real_used;
96
+	unsigned long size; /* total size */
97
+	unsigned long used; /* alloc'ed size*/
98
+	unsigned long real_used; /* used+malloc overhead*/
99
+	unsigned long max_real_used;
100 100
 	
101 101
 	struct qm_frag* first_frag;
102 102
 	struct qm_frag_end* last_frag_end;
Browse code

Fixed a typo in ROUNDTO with DBG_QM_MALLOC.

Nils Ohlmeier authored on 08/11/2002 17:30:59
Showing 1 changed files
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 /* defs*/
36 36
 #ifdef DBG_QM_MALLOC
37
-	#define ROUDNTO		 4 /* minimum possible ROUNDTO ->heavy debugging*/
37
+	#define ROUNDTO		 4 /* minimum possible ROUNDTO ->heavy debugging*/
38 38
 #else
39 39
 	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
40 40
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
Browse code

- hopefully fixed the sip_msg_cloner mem. bug - more strict mem. checking when compiling with DBG_QM_MALLOC (might catch other off by 1-7 alloc. boundary violations)

Andrei Pelinescu-Onciul authored on 08/11/2002 16:16:09
Showing 1 changed files
... ...
@@ -33,11 +33,14 @@
33 33
 
34 34
 
35 35
 /* defs*/
36
-
37
-#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
38
-						 sizeof(qm_frag)+sizeof(qm_frag_end)
39
-						 must be mutliple of ROUNDTO!
40
-					   */
36
+#ifdef DBG_QM_MALLOC
37
+	#define ROUDNTO		 4 /* minimum possible ROUNDTO ->heavy debugging*/
38
+#else
39
+	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
40
+							 sizeof(qm_frag)+sizeof(qm_frag_end)
41
+							 must be mutliple of ROUNDTO!
42
+						   */
43
+#endif
41 44
 #define MIN_FRAG_SIZE	ROUNDTO
42 45
 
43 46
 
Browse code

GPLization banner introduced to *.[hc] files

Jiri Kuthan authored on 19/09/2002 12:23:52
Showing 1 changed files
... ...
@@ -1,8 +1,32 @@
1 1
 /* $Id$
2 2
  *
3 3
  * simple & fast malloc library
4
+ *
5
+ * Copyright (C) 2001-2003 Fhg Fokus
6
+ *
7
+ * This file is part of ser, a free SIP server.
8
+ *
9
+ * ser is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version
13
+ *
14
+ * For a license to use the ser software under conditions
15
+ * other than those described here, or to purchase support for this
16
+ * software, please contact iptel.org by e-mail at the following addresses:
17
+ *    info@iptel.org
18
+ *
19
+ * ser is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of