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

📄 mk_cpu.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
{

  #if defined(XMK_UNIX) || defined(BORLAND_C) || defined(MICROSOFT_C)
    char* strg = (char*) malloc(512 * sizeof (char));
    va_list params;

    #ifdef XMK_WINDOWS
      va_start (params, format); 
    #elif defined(XMK_UNIX)
      va_start (params); 
    #endif

    vsprintf (strg, format, params);

    XMK_BEGIN_CRITICAL_PATH 
      xmk_PutString (strg);
    XMK_END_CRITICAL_PATH 

    va_end (params);
    free (strg);
  #else
	  #if defined (LOG_INTERNAL)
		char* strg = (char*) malloc(512 * sizeof (char));
		va_list params;

		#ifdef XMK_WINDOWS
		  va_start (params, format); 
		#elif defined(XMK_UNIX)
		  va_start (params); 
		#endif

		vsprintf (strg, format, params);

		XMK_BEGIN_CRITICAL_PATH 
		  xmk_PutString (strg);
		XMK_END_CRITICAL_PATH 

		va_end (params);
		free (strg);
	  #endif
  #endif
  return (0);

}

#endif /* XMK_ADD_STDIO*/
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xAlloc                                                       |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  A template for memory allocation.                                           |
|  The function is called from any place in the Cmicro Library, Cmicro Kernel  |
|  Cmicro Tester or generated C code, if memory is to be allocated dynamically |
|  The user may choose between the dynamic memory allocation functions from the|
|  C compiler or operating system or the dynamic memory allocation functions   |
|  from Cmicro.                                                                |
|                                                                              |
|  Parameter    : unsigned int Size     requested memory area block - size     |
|                                                                              |
|  Return       : SDL_Charstring        Pointer to allocated area or NULL,     |
|                                       if no dynamic allocation was possible. |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/

/*+FDEF E*/

#ifndef XNOPROTO
  void xmk_RAM_ptr xAlloc( xptrint  Size )
#else
  void xmk_RAM_ptr xAlloc( Size )
  xptrint  Size;
#endif

/*-FDEF E*/
{
  void *P;

  P = (char *)OSConnectorAlloc((unsigned)Size);
  (void)memset(P, 0, (int)Size);

  return (P);

}


/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xFree                                                        |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  This is the counter part of xAlloc. The function is called when a memory    |
|  block that was allocated with xAlloc before can be deallocated again.       |
|                                                                              |
|  Parameter    : unsigned int Size     requested memory area block - size     |
|                                                                              |
|  Return       : SDL_Charstring        Pointer to allocated area or NULL,     |
|                                       if no dynamic allocation was possible. |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/

/*+FDEF E*/

#ifndef XNOPROTO
  void xFree( void xmk_RAM_ptr xmk_RAM_ptr  P )
#else
  void xFree( P )
  void xmk_RAM_ptr xmk_RAM_ptr  P;
#endif

/*-FDEF E*/
{

  if (! *P) 
  {
    return ;
  }

  #if defined(_GCC_)
   free((char xmk_RAM_ptr)*P);
  #else
   OSConnectorFree(*P);
  #endif

  *P = (void xmk_RAM_ptr)0;

}

#if !defined(XNOUSEOFCHARSTRING) && !defined(XRESTUSEOFCHARSTRING)

/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xAlloc_SDL_Charstring                                        |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  A template for the implementation of the allocation of SDL Charstrings.     |
|  It is compiled only, if XNOUSEOFCHARSTRING is undefined.                    |
|                                                                              |
|  Parameter    : unsigned int Size     requested memory area block - size     |
|                                                                              |
|  Return       : SDL_Charstring        Pointer to allocated area or NULL,     |
|                                       if no dynamic allocation was possible. |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/

/*+FDEF E*/

#ifndef XNOPROTO
  SDL_Charstring xAlloc_SDL_Charstring (xptrint  Size)
#else
  SDL_Charstring xAlloc_SDL_Charstring ( Size )
  xptrint  Size;
#endif

/*-FDEF E*/
{
  return (SDL_Charstring)xAlloc(Size);
}


/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xFree_SDL_Charstring                                         |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  A template for the implementation of the allocation of SDL Charstrings.     |
|  It is compiled only, if XNOUSEOFCHARSTRING is undefined.                    |
|                                                                              |
|  Parameter    : void **C              pointer to mem block to be released    |
|                                                                              |
|  Return       : void                                                         |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/

/*+FDEF E*/

#ifndef XNOPROTO
  void xFree_SDL_Charstring (void xmk_RAM_ptr xmk_RAM_ptr C)
#else
  void xFree_SDL_Charstring ( C )
  void xmk_RAM_ptr xmk_RAM_ptr C;
#endif

/*-FDEF E*/
{
  xFree(C);
}

#endif /* ... !defined(XNOUSEOFCHARSTRING) && !defined(XRESTUSEOFCHARSTRING) */

#if !defined(XNOUSEOFASN1) && !defined(XNOUSEOFOCTETBITSTRING)

/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xAlloc_SDL_Bit_String                                        |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  A template for the implementation of the allocation of SDL Charstrings.     |
|  It is compiled only, if XNOUSEOFCHARSTRING is undefined.                    |
|                                                                              |
|  Parameter    : unsigned int Size     requested memory area block - size     |
|                                                                              |
|  Return       : unsigned char *       Pointer to allocated area or NULL,     |
|                                       if no dynamic allocation was possible. |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
 
/*+FDEF E*/
 
#ifndef XNOPROTO
  unsigned char * xAlloc_SDL_Bit_String ( xptrint  Size )
#else
  unsigned char * xAlloc_SDL_Bit_String ( Size )
  xptrint  Size;
#endif

/*-FDEF E*/
{
  return ( unsigned char *) xAlloc(Size);
}


/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
|  Functionname : xFree_SDL_Bit_String                                         |
+------------------------------------------------------------------------------+
|                                                                              |
|  Description :                                                               |
|  A template for the implementation of the allocation of SDL Charstrings.     |
|  It is compiled only, if XNOUSEOFCHARSTRING is undefined.                    |
|                                                                              |
|  Parameter    : void **C              pointer to mem block to be released    |
|                                                                              |
|  Return       : void                                                         |
|                                                                              |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/

/*+FDEF E*/

#ifndef XNOPROTO
  void xFree_SDL_Bit_String (void xmk_RAM_ptr xmk_RAM_ptr B)
#else
  void xFree_SDL_Bit_String ( B )
  void xmk_RAM_ptr xmk_RAM_ptr B;
#endif

/*-FDEF E*/
{
  if ( ((SDL_Bit_String *)B)->Length > 0)
  /* GBN 31.07.98 */
  {
#ifdef XMBM_COPIED
    if ( ((SDL_Bit_String *)B)->IsAssigned != XMBM_COPIED )
#endif
      xFree( (void**)&(((SDL_Bit_String *)B)->Bits) );
  }
  /* GBN 31.07.98 */

}
#endif /* ... !defined(XNOUSEOFASN1) && !defined(XNOUSEOFOCTETBITSTRING) */

#endif /* ... __MK_CPU_C_*/

⌨️ 快捷键说明

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