1 /*********************************************************************************
\r
3 * --------------------------------------------------------------------------------
\r
5 * This file is part of MiMic
\r
6 * Copyright (C)2011 Ryo Iizuka
\r
8 * MiMic is free software: you can redistribute it and/or modify
\r
9 * it under the terms of the GNU Lesser General Public License as published
\r
10 * by the Free Software Foundation, either version 3 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU Lesser General Public License
\r
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
21 * For further information please contact.
\r
23 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 *********************************************************************************/
\r
26 #include "NyLPC_stdlib.h"
\r
27 NyLPC_TUInt32 NyLPC_TUInt32_bswap(NyLPC_TUInt32 n)
\r
30 ((((NyLPC_TUInt32)(n))<<24)&0xff000000)|
\r
31 ((((NyLPC_TUInt32)(n))<< 8)&0x00ff0000)|
\r
32 ((((NyLPC_TUInt32)(n))>> 8)&0x0000ff00)|
\r
33 ((((NyLPC_TUInt32)(n))>>24)&0x000000ff));
\r
35 NyLPC_TUInt16 NyLPC_TUInt16_bswap(NyLPC_TUInt16 n)
\r
37 return NyLPC_TUInt16_BSWAP(n);
\r
40 static int _line_log_l;
\r
41 static const char* _line_log_m;
\r
42 unsigned int NyLPC_assert_counter=0;
\r
43 unsigned int NyLPC_abort_counter=0;
\r
44 unsigned int NyLPC_debug_counter=0;
\r
46 void NyLPC_assertHook(const char* m,int l)
\r
50 NyLPC_assert_counter++;
\r
53 void NyLPC_abortHook(const char* m,int l)
\r
57 NyLPC_abort_counter++;
\r
59 void NyLPC_debugHook(const char* m,int l)
\r
63 NyLPC_debug_counter++;
\r
67 NyLPC_TBool NyLPC_TCharArrayPtr_seek(struct NyLPC_TCharArrayPtr* i_struct,NyLPC_TUInt16 i_seek)
\r
69 if(i_struct->len<i_seek){
\r
70 return NyLPC_TBool_FALSE;
\r
72 i_struct->ptr+=i_seek;
\r
73 i_struct->len-=i_seek;
\r
74 return NyLPC_TBool_TRUE;
\r
77 NyLPC_TBool NyLPC_TUInt32ArrayPtr_seek(struct NyLPC_TUInt32ArrayPtr* i_struct,NyLPC_TUInt16 i_seek)
\r
79 if(i_struct->len<i_seek){
\r
80 return NyLPC_TBool_FALSE;
\r
82 i_struct->ptr+=i_seek;
\r
83 i_struct->len-=i_seek;
\r
84 return NyLPC_TBool_TRUE;
\r
86 void NyLPC_TUInt32ArrayPtr_setBuf(struct NyLPC_TUInt32ArrayPtr* i_struct,NyLPC_TUInt32* i_ptr,NyLPC_TUInt16 i_len)
\r
88 i_struct->ptr=i_ptr;
\r
89 i_struct->len=i_len;
\r
93 void NyLPC_itoa(int i_n,char* o_out,int i_digit)
\r
96 if ((sign = i_n) < 0){
\r
101 o_out[i++] = i_n % 10 + '0';
\r
102 }while ((i_n /= 10) > 0);
\r
107 NyLPC_reverse(o_out);
\r
110 void NyLPC_reverse(char* s)
\r
114 j = s + strlen(s) - 1;
\r