Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefinition of functions with MBEDTLS_PLATFORM_MEMORY and MBEDTLS_PLATFORM_CALLOC_MACRO #1706

Closed
dhhome2006 opened this issue Jun 7, 2018 · 5 comments · Fixed by #2079
Closed
Labels
bug component-platform Portability layer and build scripts

Comments

@dhhome2006
Copy link

Description

  • Type : Bug
  • Priority: Minor

Bug

OS
windows xp sp3, ubuntu

mbed TLS build:
Version : mbedtls-2.9.0-apache.tgz
Compiler: vs2010, gcc4.9

{{{
There is a compile error,

package : mbedtls-2.9.0-apache.tgz
file : platform.c
line : 40
condition : enable MBEDTLS_PLATFORM_MEMORY, MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_FREE_MACRO in config.h

current code:
#if defined(MBEDTLS_PLATFORM_MEMORY)

fixed code:
#if defined(MBEDTLS_PLATFORM_MEMORY) &&
(!defined(MBEDTLS_PLATFORM_CALLOC_MACRO) || !defined(MBEDTLS_PLATFORM_FREE_MACRO))

below is output snapshot in vs2010:
------ Build started: Project: mbedTLS, Configuration: Debug Win32 ------
platform.c
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(61): error C2365: 'calloc' : redefinition; previous definition was 'function'
c:\program files\microsoft visual studio 10.0\vc\include\stdlib.h(598) : see declaration of 'calloc'
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(62): error C2365: 'free' : redefinition; previous definition was 'function'
c:\program files\microsoft visual studio 10.0\vc\include\stdlib.h(599) : see declaration of 'free'
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(67): error C2106: '=' : left operand must be l-value
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(67): warning C4550: expression evaluates to a function which is missing an argument list
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(68): error C2106: '=' : left operand must be l-value
e:\work\gitroot\libpro\src\mbedtls\library\platform.c(68): warning C4550: expression evaluates to a function which is missing an argument list
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Eric Tung, dhhome2006@gmail.com
}}}

@simonbutcher simonbutcher changed the title a compile error Redefinition of functions with MBEDTLS_PLATFORM_MEMORY and MBEDTLS_PLATFORM_CALLOC_MACRO Jun 8, 2018
@simonbutcher simonbutcher added bug component-platform Portability layer and build scripts labels Jun 8, 2018
@simonbutcher
Copy link
Contributor

Offhand, I'm not sure the design is supposed to accommodate this configuration. However - we'll look into it, and maybe it needs better documentation or more checks, if it isn't broken as it first appears.

Thanks for the feedback!

@dhhome2006
Copy link
Author

In fact, we are using the memory pool.

{{{
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif

#include "../../../pro/pro_util/pro_a.h"
#include <stdlib.h>

void*
PRO_CALLTYPE
ProCalloc(size_t count, size_t size);

void
PRO_CALLTYPE
ProFree(void* p);

#define MBEDTLS_PLATFORM_CALLOC_MACRO ProCalloc // from a pool
#define MBEDTLS_PLATFORM_FREE_MACRO ProFree // from a pool

...

}}}

@ciarmcom
Copy link

ciarmcom commented Jun 8, 2018

ARM Internal Ref: IOTSSL-2358

@RonEld
Copy link
Contributor

RonEld commented Aug 19, 2018

from a brief look, this seems like a duplicate of #1642
please confirm

@simonbutcher
Copy link
Contributor

Closing as a duplicate of #882.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-platform Portability layer and build scripts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants