⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.h

📁 鼎鼎有名的手机mpeg4播放器smart movie-智能影院 解码内核
💻 H
字号:
/*****************************************************************************
 *
 * This program is free software ; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 ****************************************************************************/
#ifndef __UTIL_H
#define __UTIL_H

#include "rules.h"

#ifdef __PALMOS__

inline dword ByteSwap16(dword n){ return (((n << 8) & 0xff00) | ((n >> 8) & 0x00ff)); }
inline dword ByteSwap32(dword n){ return (((n << 24) & 0xff000000) | ((n << 8) & 0x00ff0000) | ((n >> 8) & 0x0000ff00) | ((n >> 24) & 0x000000ff)); }
#endif

//----------------------------
// same as standard memset, memcpy, memcmp, strlen
void MemSet(void *dst, byte c, dword len);
void MemCpy(void *dst, const void *src, dword len);

//----------------------------
void Fatal(const char *msg, dword code);

#ifndef assert

#if defined NDEBUG
#define assert(exp) ((void)0)
#else

#define assert(exp) if(!(exp)){\
   Fatal(#exp " - "__FILE__, __LINE__); }

#endif
#endif//assert

//----------------------------

#ifndef __PALMTYPES_H__ //<- defined here
#ifdef __PALMOS__
#define OffsetOf(s, m) (((dword)&((s*)1)->m)-1) //Palm compiler can't use NULL pointer in some cases
#else
#define OffsetOf(s, m) ((dword)&((s*)NULL)->m)
#endif
#endif

#ifndef __E32STD_H__ //<- this Symbian header defines these functions
                              //min & max
template<class T> const T &Max(const T &t1, const T &t2){ return t1>t2 ? t1 : t2; }
template<class T> const T &Min(const T &t1, const T &t2){ return t1<t2 ? t1 : t2; }
template<class T> T Abs(T t){ return t>=0 ? t : -t; }

void *operator new(size_t sz);
void operator delete(void*);

//#ifndef LINUX
                              //placement new/delete
inline void *operator new(size_t sz, void *p){ return p; }
inline void operator delete(void*, void*){ }

//#endif
#endif

void *operator new(size_t sz, bool);
inline void operator delete(void *vp, bool){ operator delete(vp); }

inline void *operator new[](size_t sz){ return operator new(sz); }
inline void operator delete[](void *vp){ operator delete(vp); }

inline void *operator new[](size_t sz, bool l){ return operator new(sz, l); }
inline void operator delete[](void *vp, bool){ operator delete[](vp); }

//----------------------------

#ifdef __PALMOS__

                              //special flags, OR'd with 'num_args' param of Call68KFunc
#define CALL68K_FIRST_IS_WORD 0x100 //first parameter is 16-bi
#define CALL68K_RETURN_PTR 0x200    //called 68K function returns pointer

//----------------------------
// Function for calling 68K system code from ARM code.
dword Call68KFunc(dword trap, dword num_args, ...);

#endif

//----------------------------

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -