Tools Mail Account <tools@qnx.com> wrote:
Hello,
Since it is included in the 6.2 beta I’m posting fixed malloc_g/malloc.h header
Regards,
Marcin
/*
- malloc.h Memory allocation functions
-
- Copyright (C) by QNX Software Systems 1995-1999. All rights reserved.
*/
#ifndef _MALLOC_H_INCLUDED
#if defined(WATCOMC) && !defined(_ENABLE_AUTODEPEND)
#pragma read_only_file;
#endif
#ifndef __PLATFORM_H_INCLUDED
#include <sys/platform.h>
#endif
#if !defined(__cplusplus) || defined(_STD_USING) || defined(_GLOBAL_USING)
#define _MALLOC_H_INCLUDED
#endif
#ifndef _MALLOC_H_DECLARED
#define _MALLOC_H_DECLARED
#include <_pack64.h>
_C_STD_BEGIN
#if defined(__SIZE_T)
typedef __SIZE_T size_t;
#undef __SIZE_T
#endif
_C_STD_END
#if defined(__EXT_QNX) && !defined(_alloca)
#ifndef _ALLOCA_H_INCLUDED
#include <alloca.h>
#endif
#endif
__BEGIN_DECLS
_C_STD_BEGIN
extern void *calloc(size_t __n, size_t __size);
extern void *malloc(size_t __size);
extern void *realloc(void *__ptr, size_t __size);
extern void free(void *__ptr);
_C_STD_END
#if defined(__EXT_QNX) /* Approved 1003.1d D14 */
extern int posix_memalign(void **__memptr, _CSTD size_t __alignment, _CSTD size_t __size);
#endif
#if defined(__EXT_QNX)
extern int cfree(void *__ptr);
extern void *_scalloc(_CSTD size_t __size);
extern void *_smalloc(_CSTD size_t __size);
extern void *_srealloc(void *__ptr, _CSTD size_t __old_size, _CSTD size_t __new_size);
extern void _sfree(void *__ptr, _CSTD size_t __size);
#endif
#if defined(__EXT_QNX) /* SVID/XPG/ELIX functions /
/ This shouldn’t really be an enum for C++ compatibility */
enum malloc_opt_cmds {
MALLOC_VERIFY,
MALLOC_VERIFY_ON,
MALLOC_STATS,
MALLOC_FREE_CHECK,
MALLOC_ARENA_SIZE,
MALLOC_MONOTONIC_GROWTH,
MALLOC_LAST
};
/* Don’t enum these, so we don’t get coercion errors if the caller is C++ */
#define M_MXFAST (int)MALLOC_LAST
#define M_NLBLKS (int)(MALLOC_LAST+1)
#define M_GRAIN (int)(MALLOC_LAST+2)
#define M_TRIM_THRESHOLD (int)(MALLOC_LAST+3)
#define M_TOP_PAD (int)(MALLOC_LAST+4)
#define M_MMAP_THRESHOLD (int)(MALLOC_LAST+5)
#define M_MMAP_MAX (int)(MALLOC_LAST+6)
struct malloc_stats {
unsigned m_small_freemem;/* memory in free small blocks /
unsigned m_freemem; / memory in free big blocks /
unsigned m_small_overhead;/ space in header block headers /
unsigned m_overhead; / space used by block headers /
unsigned m_small_allocmem;/ space in small blocks in use /
unsigned m_allocmem; / space in big blocks in use /
unsigned m_coreallocs; / number of core allocations performed /
unsigned m_corefrees; / number of core de-allocations performed /
unsigned m_heapsize; / size of the arena /
unsigned m_frees; / number of frees performed /
unsigned m_allocs; / number of allocations performed /
unsigned m_reallocs; / number of realloc functions performed /
unsigned m_small_blocks; / number of small blocks /
unsigned m_blocks; / number of big blocks /
unsigned m_hblocks; / number of header blocks */
};
struct mallinfo {
int arena; /* size of the arena /
int ordblks;/ number of big blocks in use /
int smblks; / number of small blocks in use /
int hblks; / number of header blocks in use /
int hblkhd; / space in header block headers /
int usmblks;/ space in small blocks in use /
int fsmblks;/ memory in free small blocks /
int uordblks;/ space in big blocks in use /
int fordblks;/ memory in free big blocks /
int keepcost;/ penalty if M_KEEP is used – not used */
};
enum mcheck_status {
MCHECK_DISABLED = -1, MCHECK_OK = 0, MCHECK_HEAD, MCHECK_TAIL, MCHECK_FREE
};
extern struct mallinfo mallinfo(void);
extern int mallopt(int __cmd, int __value);
extern enum mcheck_status mprobe(void __ptr);
extern int mcheck(void (__abort_fn)(enum mcheck_status __status));
extern void *memalign(_CSTD size_t __alignment, _CSTD size_t __size);
extern void *valloc(_CSTD size_t __size);
#endif
__END_DECLS
#include <_packpop.h>
#include <_packpop.h>
#ifndef MALLOC_DEBUG
#define MALLOC_DEBUG
#endif
#ifndef MALLOC_PC
#define MALLOC_PC
#endif
#ifdef MALLOC_GUARD
#undef MALLOC_GUARD
#endif
#include <malloc_g/malloc-lib.h>
#endif
#endif /* _MALLOC_H_INCLUDED */
Rejean Senecal <> rsenecal@oerlikon.ca-no-spam> > wrote:
Hello Rejean,
There was a problem in the header malloc_g/malloc.h, it is fixed
in 6.2.
Regards,
Marcin
When compiling this simple program with QCC or qcc
#include <stdio.h
#include <iostream.h
#include <malloc_g/malloc.h
#include “test.hpp”
void main()
{
cout << “Hello world” << endl;
}
I’m getting theses error.
In file included from test.cpp:3:
/usr/include/malloc_g/malloc.h:50: multiple definition of enum malloc_opt_cmds' /usr/include/malloc_g/malloc.h:50: redefinition of
enum malloc_opt_cmds
MALLOC_VERIFY’
/usr/include/malloc.h:64: enum malloc_opt_cmds MALLOC_VERIFY' previously defined here /usr/include/malloc_g/malloc.h:51: redefinition of
enum malloc_opt_cmds
MALLOC_VERIFY_ON’
/usr/include/malloc.h:65: enum malloc_opt_cmds MALLOC_VERIFY_ON' previously defined here /usr/include/malloc_g/malloc.h:52: redefinition of
enum malloc_opt_cmds
MALLOC_STATS’
/usr/include/malloc.h:66: enum malloc_opt_cmds MALLOC_STATS' previously defined here /usr/include/malloc_g/malloc.h:53: redefinition of
enum malloc_opt_cmds
MALLOC_FREE_CHECK’
/usr/include/malloc.h:67: enum malloc_opt_cmds MALLOC_FREE_CHECK' previously defined here /usr/include/malloc_g/malloc.h:54: redefinition of
enum malloc_opt_cmds
MALLOC_ARENA_SIZE’
/usr/include/malloc.h:68: enum malloc_opt_cmds MALLOC_ARENA_SIZE' previously defined here /usr/include/malloc_g/malloc.h:55: redefinition of
enum malloc_opt_cmds
MALLOC_MONOTONIC_GROWTH’
/usr/include/malloc.h:69: enum malloc_opt_cmds MALLOC_MONOTONIC_GROWTH' previously defined here /usr/include/malloc_g/malloc.h:57: redefinition of
enum malloc_opt_cmds
MALLOC_LAST’
/usr/include/malloc.h:71: enum malloc_opt_cmds MALLOC_LAST' previously defined here /usr/include/malloc_g/malloc.h:68: redefinition of
struct malloc_stats’
/usr/include/malloc.h:98: previous definition here
/usr/include/malloc_g/malloc.h:86: redefinition of struct mallinfo' /usr/include/malloc.h:111: previous definition here /usr/include/malloc_g/malloc.h> :100: > multiple definition of
enum
mcheck_status’
/usr/include/malloc_g/malloc.h> > redefinition of enum mcheck_status MCHECK_DISABLED' /usr/include/malloc.h:114:
enum mcheck_status MCHECK_DISABLED’ previously
defined here
/usr/include/malloc_g/malloc.h> > redefinition of enum mcheck_status MCHECK_OK' /usr/include/malloc.h:114:
enum mcheck_status MCHECK_OK’ previously defined
here
/usr/include/malloc_g/malloc.h> > redefinition of enum mcheck_status MCHECK_HEAD' /usr/include/malloc.h:114:
enum mcheck_status MCHECK_HEAD’ previously
defined here
/usr/include/malloc_g/malloc.h> > redefinition of enum mcheck_status MCHECK_TAIL' /usr/include/malloc.h:114:
enum mcheck_status MCHECK_TAIL’ previously
defined here
/usr/include/malloc_g/malloc.h:101: redefinition of enum mcheck_status MCHECK_FREE' /usr/include/malloc.h:115:
enum mcheck_status MCHECK_FREE’ previously
defined here
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33
How can I fix this. Can someone else try this.
–
********** 2002 FIFA World Cup Korea/Japan ************