3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #ifndef __MSG_MEMORY_H__
32 #define __MSG_MEMORY_H__
35 /*==================================================================================================
37 ==================================================================================================*/
43 /*==================================================================================================
45 ==================================================================================================*/
46 #define GETSP() ({ unsigned int sp; asm volatile ("mov %0,sp " : "=r"(sp) ); sp;})
48 #define PAGE_SIZE (1 << 12)
49 #define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
50 #define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
51 #define PAGE_ALIGN(addr) _ALIGN_DOWN(addr, PAGE_SIZE)
54 /*==================================================================================================
56 ==================================================================================================*/
63 unsigned int stacktop;
68 snprintf(buf, BUF_SIZE, "/proc/%d/maps",getpid());
69 file = fopen(buf,"r");
70 while(fgets(buf, BUF_SIZE, file) != NULL) {
71 if(strstr(buf, "[stack]")){
79 sscanf(buf,"%x-",&stacktop);
80 if(madvise((void*)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp)-stacktop, MADV_DONTNEED) < 0)
81 perror("stack madvise fail");
86 void MsgReleaseMemory();
89 #endif // __MSG_MEMORY_H__