mframe.foot
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:2k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. inline static void*
  2. mframe_arg_addr(arglist_t argf, NSArgumentInfo *info)
  3. {
  4.   int offset = info->offset;
  5. #if WORDS_BIGENDIAN
  6.   if (info->size < sizeof (int))
  7.     {
  8.       offset += sizeof(int) - info->size;
  9.     }
  10. #endif
  11.   if (info->isReg)
  12.     {
  13.       return(argf->arg_regs + offset);
  14.     }
  15.   else
  16.     {
  17.       return(argf->arg_ptr + offset);
  18.     }
  19. }
  20. inline static void
  21. mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
  22. {
  23. #if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL
  24.   const char *typ = info->type;
  25. #endif
  26. #if MFRAME_STRUCT_BYREF
  27.   /*
  28.    * If structures are passed in the stack frame by reference - we need
  29.    * to copy the actual structure, rather than it's pointer.
  30.    */
  31.   if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
  32.     {
  33.       memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size);
  34.     }
  35.   else
  36. #endif
  37. #if MFRAME_FLT_IN_FRAME_AS_DBL
  38.   if (*typ == _C_FLT)
  39.     {
  40.       *(float*)buffer = (float)*(double*)mframe_arg_addr(argf, info);
  41.     }
  42.   else
  43. #endif
  44.   memcpy(buffer, mframe_arg_addr(argf, info), info->size);
  45. }
  46. inline static void
  47. mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
  48. {
  49. #if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL
  50.   const char *typ = info->type;
  51. #endif
  52. #if MFRAME_STRUCT_BYREF
  53.   /*
  54.    * If structures are passed in the stack frame by reference - we need
  55.    * to copy a pointer onto the stack rather than the actual structure.
  56.    */
  57.   if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
  58.     {
  59.       memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*));
  60.     }
  61.   else
  62. #endif
  63. #if MFRAME_FLT_IN_FRAME_AS_DBL
  64.   if (*typ == _C_FLT)
  65.     {
  66.       *(double*)mframe_arg_addr(argf, info) = *(float*)buffer;
  67.     }
  68.   else
  69. #endif
  70.   memcpy(mframe_arg_addr(argf, info), buffer, info->size);
  71. }
  72. inline static void
  73. mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info)
  74. {
  75. #if MFRAME_STRUCT_BYREF
  76.   const char *typ = info->type;
  77.   /*
  78.    * If structures are passed in the stack frame by reference - we need
  79.    * to copy a pointer onto the stack rather than the actual structure.
  80.    */
  81.   if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
  82.     {
  83.       memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*));
  84.     }
  85.   else
  86. #endif
  87.     memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size);
  88. }
  89. #endif /* __mframe_h_GNUSTEP_BASE_INCLUDE */