mirror of https://github.com/ARMmbed/mbed-os.git
Add IAR support
Make the following changes for IAR support: -define __deprecated_message for IAR -fix python error in iar.py -move variable length array in buffered serial from cpp file to c file. IAR only supports variable length arrays in c.
parent
8a6e9c3a26
commit
960941cb0a
|
@ -30,6 +30,8 @@
|
|||
# ifndef __deprecated_message
|
||||
# if defined(__CC_ARM)
|
||||
# define __deprecated_message(msg) __attribute__((deprecated))
|
||||
# elif defined (__ICCARM__)
|
||||
# define __deprecated_message(msg)
|
||||
# else
|
||||
# define __deprecated_message(msg) __attribute__((deprecated(msg)))
|
||||
# endif
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mbed_error.h"
|
||||
|
||||
size_t BufferedSerialThunk(void *buf_serial, const void *s, size_t length);
|
||||
|
||||
int BufferedPrintfC(void *stream, int size, const char* format, va_list arg)
|
||||
{
|
||||
int r;
|
||||
char buffer[size];
|
||||
memset(buffer, 0, size);
|
||||
r = vsprintf(buffer, format, arg);
|
||||
// this may not hit the heap but should alert the user anyways
|
||||
if(r > (int32_t) size) {
|
||||
error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__, size, r);
|
||||
return 0;
|
||||
}
|
||||
if ( r > 0 ) {
|
||||
BufferedSerialThunk(stream, buffer, r);
|
||||
}
|
||||
return r;
|
||||
}
|
|
@ -23,6 +23,8 @@
|
|||
#include "BufferedSerial.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
extern "C" int BufferedPrintfC(void *stream, int size, const char* format, va_list arg);
|
||||
|
||||
BufferedSerial::BufferedSerial(PinName tx, PinName rx, uint32_t buf_size, uint32_t tx_multiple, const char* name)
|
||||
: RawSerial(tx, rx) , _rxbuf(buf_size), _txbuf((uint32_t)(tx_multiple*buf_size))
|
||||
{
|
||||
|
@ -79,26 +81,18 @@ int BufferedSerial::puts(const char *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" size_t BufferedSerialThunk(void *buf_serial, const void *s, size_t length)
|
||||
{
|
||||
BufferedSerial *buffered_serial = (BufferedSerial *)buf_serial;
|
||||
return buffered_serial->write(s, length);
|
||||
}
|
||||
|
||||
int BufferedSerial::printf(const char* format, ...)
|
||||
{
|
||||
char buffer[this->_buf_size];
|
||||
memset(buffer,0,this->_buf_size);
|
||||
int r = 0;
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
r = vsprintf(buffer, format, arg);
|
||||
// this may not hit the heap but should alert the user anyways
|
||||
if(r > (int32_t) this->_buf_size) {
|
||||
error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__,this->_buf_size,r);
|
||||
va_end(arg);
|
||||
return 0;
|
||||
}
|
||||
int r = BufferedPrintfC((void*)this, this->_buf_size, format, arg);
|
||||
va_end(arg);
|
||||
if ( r > 0 ) {
|
||||
r = BufferedSerial::write(buffer, r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class IAR(mbedToolchain):
|
|||
cmd = [self.ld, "-o", output, "--skip_dynamic_initialization", "--map=%s" % map_file] + objects + libraries
|
||||
|
||||
if mem_map:
|
||||
args.extend(["--config", mem_map])
|
||||
cmd.extend(["--config", mem_map])
|
||||
|
||||
# Call cmdline hook
|
||||
cmd = self.hook.get_cmdline_linker(cmd)
|
||||
|
|
Loading…
Reference in New Issue