mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 14:58:25 +00:00
backport astmm + sparch fixes from the trunk
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@15743 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
AGIS=agi-test.agi eagi-test eagi-sphinx-test
|
AGIS=agi-test.agi eagi-test eagi-sphinx-test
|
||||||
|
|
||||||
CFLAGS+=
|
CFLAGS+=-DNO_AST_MM
|
||||||
|
|
||||||
LIBS=
|
LIBS=
|
||||||
ifeq ($(OSARCH),SunOS)
|
ifeq ($(OSARCH),SunOS)
|
||||||
|
|||||||
7
astmm.c
7
astmm.c
@@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/options.h"
|
#include "asterisk/options.h"
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
#include "asterisk/strings.h"
|
#include "asterisk/strings.h"
|
||||||
|
#include "asterisk/unaligned.h"
|
||||||
|
|
||||||
#define SOME_PRIME 563
|
#define SOME_PRIME 563
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file,
|
|||||||
regions[hash] = reg;
|
regions[hash] = reg;
|
||||||
reg->fence = FENCE_MAGIC;
|
reg->fence = FENCE_MAGIC;
|
||||||
fence = (ptr + reg->len);
|
fence = (ptr + reg->len);
|
||||||
*fence = FENCE_MAGIC;
|
put_unaligned_uint32(fence, FENCE_MAGIC);
|
||||||
}
|
}
|
||||||
ast_mutex_unlock(®lock);
|
ast_mutex_unlock(®lock);
|
||||||
if (!reg) {
|
if (!reg) {
|
||||||
@@ -161,7 +162,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha
|
|||||||
fflush(mmlog);
|
fflush(mmlog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*fence != FENCE_MAGIC) {
|
if (get_unaligned_uint32(fence) != FENCE_MAGIC) {
|
||||||
fprintf(stderr, "WARNING: High fence violation at %p, in %s of %s, line %d\n", reg->data, reg->func, reg->file, reg->lineno);
|
fprintf(stderr, "WARNING: High fence violation at %p, in %s of %s, line %d\n", reg->data, reg->func, reg->file, reg->lineno);
|
||||||
if (mmlog) {
|
if (mmlog) {
|
||||||
fprintf(mmlog, "%ld - WARNING: High fence violation at %p, in %s of %s, line %d\n", time(NULL), reg->data, reg->func, reg->file, reg->lineno);
|
fprintf(mmlog, "%ld - WARNING: High fence violation at %p, in %s of %s, line %d\n", time(NULL), reg->data, reg->func, reg->file, reg->lineno);
|
||||||
@@ -296,7 +297,7 @@ static int handle_show_memory(int fd, int argc, char *argv[])
|
|||||||
fflush(mmlog);
|
fflush(mmlog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*fence != FENCE_MAGIC) {
|
if (get_unaligned_uint32(fence) != FENCE_MAGIC) {
|
||||||
fprintf(stderr, "WARNING: High fence violation at %p, in %s of %s, line %d\n", reg->data, reg->func, reg->file, reg->lineno);
|
fprintf(stderr, "WARNING: High fence violation at %p, in %s of %s, line %d\n", reg->data, reg->func, reg->file, reg->lineno);
|
||||||
if (mmlog) {
|
if (mmlog) {
|
||||||
fprintf(mmlog, "%ld - WARNING: High fence violation at %p, in %s of %s, line %d\n", time(NULL), reg->data, reg->func, reg->file, reg->lineno);
|
fprintf(mmlog, "%ld - WARNING: High fence violation at %p, in %s of %s, line %d\n", time(NULL), reg->data, reg->func, reg->file, reg->lineno);
|
||||||
|
|||||||
@@ -33,21 +33,18 @@ char* strsep(char** str, const char* delims)
|
|||||||
int setenv(const char *name, const char *value, int overwrite)
|
int setenv(const char *name, const char *value, int overwrite)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int buflen, ret;
|
int buflen;
|
||||||
|
|
||||||
buflen = strlen(name) + strlen(value) + 2;
|
buflen = strlen(name) + strlen(value) + 2;
|
||||||
if ((buf = malloc(buflen)) == NULL)
|
if (!(buf = alloca(buflen)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!overwrite && getenv(name))
|
if (!overwrite && getenv(name))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
snprintf(buf, buflen, "%s=%s", name, value);
|
snprintf(buf, buflen, "%s=%s", name, value);
|
||||||
ret = putenv(buf);
|
|
||||||
|
|
||||||
free(buf);
|
return putenv(buf);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int unsetenv(const char *name)
|
int unsetenv(const char *name)
|
||||||
|
|||||||
Reference in New Issue
Block a user