Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
7c744ce1
提交
7c744ce1
authored
8月 05, 2013
作者:
Steve Underwood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added custom allocation functions to spandsp
上级
95ae3732
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
292 行增加
和
3 行删除
+292
-3
configure.ac
libs/spandsp/configure.ac
+3
-0
Makefile.am
libs/spandsp/src/Makefile.am
+2
-0
alloc.c
libs/spandsp/src/alloc.c
+128
-0
spandsp.h.in
libs/spandsp/src/spandsp.h.in
+1
-0
alloc.h
libs/spandsp/src/spandsp/alloc.h
+63
-0
Makefile.am
libs/spandsp/tests/Makefile.am
+4
-0
alloc_tests.c
libs/spandsp/tests/alloc_tests.c
+78
-0
v18_tests.c
libs/spandsp/tests/v18_tests.c
+13
-3
没有找到文件。
libs/spandsp/configure.ac
浏览文件 @
7c744ce1
...
...
@@ -138,6 +138,7 @@ AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support])
AC_ARG_ENABLE(avx2, [ --enable-avx2 Enable AVX2 support])
AC_ARG_ENABLE(neon, [ --enable-neon Enable NEON support])
AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
# The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp
AC_ARG_ENABLE(builtin_tiff,
[AC_HELP_STRING([--enable-builtin-tiff],[build with builtin libtiff])],[enable_builtin_tiff="$enableval"],[enable_builtin_tiff="no"])
...
...
@@ -164,6 +165,8 @@ fi
AX_C99_FLEXIBLE_ARRAY
AC_CHECK_FUNCS([aligned_alloc])
AC_CHECK_FUNCS([memalign])
AC_CHECK_FUNCS([posix_memalign])
AC_CHECK_FUNCS([memmove])
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([select])
...
...
libs/spandsp/src/Makefile.am
浏览文件 @
7c744ce1
...
...
@@ -84,6 +84,7 @@ lib_LTLIBRARIES = libspandsp.la
libspandsp_la_SOURCES
=
ademco_contactid.c
\
adsi.c
\
alloc.c
\
async.c
\
at_interpreter.c
\
awgn.c
\
...
...
@@ -178,6 +179,7 @@ libspandsp_la_LDFLAGS = -version-info @SPANDSP_LT_CURRENT@:@SPANDSP_LT_REVISION@
nobase_include_HEADERS
=
spandsp/ademco_contactid.h
\
spandsp/adsi.h
\
spandsp/alloc.h
\
spandsp/async.h
\
spandsp/arctan2.h
\
spandsp/at_interpreter.h
\
...
...
libs/spandsp/src/alloc.c
0 → 100644
浏览文件 @
7c744ce1
/*
* SpanDSP - a series of DSP components for telephony
*
* alloc.c - memory allocation handling.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2013 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#define __USE_ISOC11
#include <stdlib.h>
#if defined(HAVE_MALLOC_H)
#include <malloc.h>
#endif
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#if defined(HAVE_POSIX_MEMALIGN)
static
void
*
fake_posix_memalign
(
size_t
alignment
,
size_t
size
);
#endif
static
void
*
fake_aligned_alloc
(
size_t
alignment
,
size_t
size
);
span_alloc_t
__span_alloc
=
malloc
;
#if defined(HAVE_ALIGNED_ALLOC)
span_aligned_alloc_t
__span_aligned_alloc
=
aligned_alloc
;
#elif defined(HAVE_MEMALIGN)
span_aligned_alloc_t
__span_aligned_alloc
=
memalign
;
#elif defined(HAVE_POSIX_MEMALIGN)
span_aligned_alloc_t
__span_aligned_alloc
=
fake_posix_memalign
;
#else
span_aligned_alloc_t
__span_aligned_alloc
=
fake_aligned_alloc
;
#endif
span_realloc_t
__span_realloc
=
realloc
;
span_free_t
__span_free
=
free
;
#if defined(HAVE_POSIX_MEMALIGN)
static
void
*
fake_posix_memalign
(
size_t
alignment
,
size_t
size
)
{
void
*
ptr
;
/* Make posix_memalign look like the more modern aligned_alloc */
posix_memalign
(
&
ptr
,
alignment
,
size
);
return
ptr
;
}
/*- End of function --------------------------------------------------------*/
#endif
static
void
*
fake_aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
return
NULL
;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
*
)
span_alloc
(
size_t
size
)
{
return
__span_alloc
(
size
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
*
)
span_aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
return
__span_aligned_alloc
(
alignment
,
size
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
*
)
span_realloc
(
void
*
ptr
,
size_t
size
)
{
return
__span_realloc
(
ptr
,
size
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
)
span_free
(
void
*
ptr
)
{
__span_free
(
ptr
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_alloc_t
custom_alloc
,
span_aligned_alloc_t
custom_aligned_alloc
,
span_realloc_t
custom_realloc
,
span_free_t
custom_free
)
{
if
(
custom_alloc
==
NULL
||
custom_realloc
==
NULL
||
custom_free
==
NULL
)
return
-
1
;
__span_alloc
=
custom_alloc
;
if
(
custom_aligned_alloc
)
__span_aligned_alloc
=
custom_aligned_alloc
;
else
__span_aligned_alloc
=
fake_aligned_alloc
;
__span_realloc
=
custom_realloc
;
__span_free
=
custom_free
;
return
0
;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
libs/spandsp/src/spandsp.h.in
浏览文件 @
7c744ce1
...
...
@@ -48,6 +48,7 @@
#include <tiffio.h>
#include <spandsp/telephony.h>
#include <spandsp/alloc.h>
#include <spandsp/fast_convert.h>
#include <spandsp/logging.h>
#include <spandsp/complex.h>
...
...
libs/spandsp/src/spandsp/alloc.h
0 → 100644
浏览文件 @
7c744ce1
/*
* SpanDSP - a series of DSP components for telephony
*
* alloc.h - memory allocation handling.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2013 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*! \file */
#if !defined(_SPANDSP_ALLOC_H_)
#define _SPANDSP_ALLOC_H_
typedef
void
*
(
*
span_alloc_t
)(
size_t
size
);
typedef
void
*
(
*
span_aligned_alloc_t
)(
size_t
alignment
,
size_t
size
);
typedef
void
*
(
*
span_realloc_t
)(
void
*
ptr
,
size_t
size
);
typedef
void
(
*
span_free_t
)(
void
*
ptr
);
#if defined(__cplusplus)
extern
"C"
{
#endif
/* Allocate size bytes of memory. */
SPAN_DECLARE
(
void
*
)
span_alloc
(
size_t
size
);
/* Allocate size bytes allocated to ALIGNMENT bytes. */
SPAN_DECLARE
(
void
*
)
span_aligned_alloc
(
size_t
alignment
,
size_t
size
);
/* Re-allocate the previously allocated block in ptr, making the new block size bytes long. */
SPAN_DECLARE
(
void
*
)
span_realloc
(
void
*
ptr
,
size_t
size
);
/* Free a block allocated by span_alloc, span_aligned_alloc, or span_realloc. */
SPAN_DECLARE
(
void
)
span_free
(
void
*
ptr
);
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_alloc_t
custom_alloc
,
span_aligned_alloc_t
custom_aligned_alloc
,
span_realloc_t
custom_realloc
,
span_free_t
custom_free
);
#if defined(__cplusplus)
}
#endif
#endif
/*- End of file ------------------------------------------------------------*/
libs/spandsp/tests/Makefile.am
浏览文件 @
7c744ce1
...
...
@@ -52,6 +52,7 @@ LIBDIR = -L$(top_builddir)/src
noinst_PROGRAMS
=
ademco_contactid_tests
\
adsi_tests
\
alloc_tests
\
async_tests
\
at_interpreter_tests
\
awgn_tests
\
...
...
@@ -146,6 +147,9 @@ ademco_contactid_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIB
adsi_tests_SOURCES
=
adsi_tests.c
adsi_tests_LDADD
=
-L
$(top_builddir)
/spandsp-sim
-lspandsp-sim
$(LIBDIR)
-lspandsp
alloc_tests_SOURCES
=
alloc_tests.c
alloc_tests_LDADD
=
$(LIBDIR)
-lspandsp
async_tests_SOURCES
=
async_tests.c
async_tests_LDADD
=
$(LIBDIR)
-lspandsp
...
...
libs/spandsp/tests/alloc_tests.c
0 → 100644
浏览文件 @
7c744ce1
/*
* SpanDSP - a series of DSP components for telephony
*
* alloc_tests.c - memory allocation handling tests.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2013 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*! \file */
/*! \page alloc_tests_page Memory allocation tests
\section alloc_tests_page_sec_1 What does it do?
???.
\section alloc_tests_page_sec_2 How does it work?
???.
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#include <stdlib.h>
#include <malloc.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include "spandsp.h"
int
main
(
int
argc
,
char
*
argv
[])
{
void
*
a
;
void
*
b
;
void
*
c
;
if
(
span_mem_allocators
(
malloc
,
memalign
,
realloc
,
free
))
{
printf
(
"Failed
\n
"
);
exit
(
2
);
}
a
=
span_alloc
(
42
);
b
=
span_aligned_alloc
(
8
,
42
);
c
=
span_realloc
(
NULL
,
42
);
printf
(
"%p %p %p
\n
"
,
a
,
b
,
c
);
span_free
(
a
);
span_free
(
b
);
span_free
(
c
);
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
libs/spandsp/tests/v18_tests.c
浏览文件 @
7c744ce1
...
...
@@ -7473,7 +7473,7 @@ static int test_x_01(void)
result
[
0
][
0
]
=
result
[
1
][
0
]
=
'\0'
;
v18_put
(
v18
[
0
],
"z
"
,
1
);
v18_put
(
v18
[
0
],
"z
abcdefghijklmnopq"
,
-
1
);
for
(
i
=
0
;
i
<
10000
;
i
++
)
{
for
(
j
=
0
;
j
<
2
;
j
++
)
...
...
@@ -7518,7 +7518,7 @@ static int test_x_01(void)
v18_free
(
v18
[
0
]);
v18_free
(
v18
[
1
]);
ref
=
"cdefghij"
;
printf
(
"Result:
\n
%s
\n
"
,
result
[
0
]);
printf
(
"Result:
\n
%s
\n
"
,
result
[
1
]);
printf
(
"Reference result:
\n
%s
\n
"
,
ref
);
if
(
unexpected_echo
||
strcmp
(
result
[
1
],
ref
)
!=
0
)
return
-
1
;
...
...
@@ -7864,9 +7864,18 @@ static int test_x_04(void)
static
void
x_05_put_text_msg
(
void
*
user_data
,
const
uint8_t
*
msg
,
int
len
)
{
if
(
user_data
==
NULL
)
{
/* Gather the received characters, which should be like the transmitted characters,
but with the first three characters missing. */
strcat
(
result
[
0
],
(
const
char
*
)
msg
);
}
else
{
/* Receiving a character from the far end should block out its receiver
for a while. If we send a stream of DTMF back, the first few characters
(actually 3 for this particular text string) should be lost. */
v18_put
(
v18
[
1
],
"behknqtwz"
,
9
);
}
}
/*- End of function --------------------------------------------------------*/
...
...
@@ -7920,7 +7929,8 @@ static int test_x_05(void)
result
[
0
][
0
]
=
result
[
1
][
0
]
=
'\0'
;
v18_put
(
v18
[
0
],
"e"
,
1
);
/* Sending a character should block out the receiver for a while */
v18_put
(
v18
[
0
],
"z"
,
1
);
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论