]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR/src/cg_src/r_cg_sbrk.c
823d383ec2eb709be89f8f76c4146d02a0a7022f
[freertos] / FreeRTOS / Demo / RX100_RX113-RSK_GCC_e2studio_IAR / src / cg_src / r_cg_sbrk.c
1 /***********************************************************************************************************************\r
2 * DISCLAIMER\r
3 * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products.\r
4 * No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all\r
5 * applicable laws, including copyright laws. \r
6 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIESREGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED\r
7 * OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
8 * NON-INFRINGEMENT.  ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY\r
9 * LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT,\r
10 * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR\r
11 * ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
12 * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability \r
13 * of this software. By using this software, you agree to the additional terms and conditions found by accessing the \r
14 * following link:\r
15 * http://www.renesas.com/disclaimer\r
16 *\r
17 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.\r
18 ***********************************************************************************************************************/\r
19 \r
20 /***********************************************************************************************************************\r
21 * File Name    : r_cg_sbrk.c\r
22 * Version      : Code Generator for RX113 V1.02.01.02 [28 May 2015]\r
23 * Device(s)    : R5F51138AxFP\r
24 * Tool-Chain   : CCRX\r
25 * Description  : Program of sbrk.\r
26 * Creation Date: 21/09/2015\r
27 ***********************************************************************************************************************/\r
28 \r
29 /***********************************************************************************************************************\r
30 Pragma directive\r
31 ***********************************************************************************************************************/\r
32 /* Start user code for pragma. Do not edit comment generated here */\r
33 /* End user code. Do not edit comment generated here */\r
34 \r
35 /***********************************************************************************************************************\r
36 Includes\r
37 ***********************************************************************************************************************/\r
38 #include "r_cg_macrodriver.h"\r
39 #include <stddef.h>\r
40 #include <stdio.h>\r
41 #include "r_cg_sbrk.h"\r
42 #include "r_cg_userdefine.h"\r
43 \r
44 /***********************************************************************************************************************\r
45 Global variables and functions\r
46 ***********************************************************************************************************************/\r
47 \r
48 int8_t  *sbrk(size_t size);\r
49 \r
50 extern int8_t *_s1ptr;\r
51 \r
52 union HEAP_TYPE\r
53 {\r
54     int16_t  dummy ;            /* Dummy for 4-byte boundary */\r
55     int8_t heap[HEAPSIZE];      /* Declaration of the area managed by sbrk */\r
56 };\r
57 \r
58 static union HEAP_TYPE heap_area ;\r
59 \r
60 /* End address allocated by sbrk    */\r
61 static int8_t *brk = (int8_t *) &heap_area;\r
62 \r
63 /**************************************************************************/\r
64 /*      sbrk:Memory area allocation                                       */\r
65 /*      Return value:Start address of allocated area    (Pass)            */\r
66 /*                       -1                             (Failure)         */\r
67 /**************************************************************************/\r
68 int8_t *sbrk(size_t size)                       /* Assigned area size   */\r
69 {\r
70     int8_t  *p;\r
71 \r
72     if (brk+size > heap_area.heap + HEAPSIZE)   /* Empty area size      */\r
73     {\r
74         p = (int8_t *)-1;\r
75     }\r
76     else\r
77     {\r
78         p = brk;                                /* Area assignment      */\r
79         brk += size;                            /* End address update   */\r
80     }\r
81 \r
82     return p;\r
83 }\r
84 \r
85 /* Start user code for adding. Do not edit comment generated here */\r
86 /* End user code. Do not edit comment generated here */\r