netmsgs/libnetmsgs/nmLibPack.c
int nmPackS64(long long val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
{
  static size_t fvalLen = NMFVAL_LEN_S64;     // message field value length

  uint_t        uMSB;     // most significant bytes
  uint_t        uLSB;     // least signifcant bytes

  _NM_CHK_MEM(bufSize, fvalLen);

  // 8-byte signed long long
  if( sizeof(long long) == fvalLen )
  {
    switch( eEndian )
    {
      case NMEndianLittle:
        PACKLITTLE(val, buf);
        break;
      case NMEndianNative:
        PACKNATIVE(val, buf);
        break;
      case NMEndianBig:
      default:
        PACKBIG(val, buf);
        break;
    }
  }

  // 4-byte signed long long
  else
  {
    _NM_CHK_ARCH(val, (size_t)NMFVAL_LEN_S32);

    uMSB = val & 0x80000000? 0xffffffff: 0x00000000;  // extend sign
    uLSB = (uint_t)val;

    switch( eEndian )
    {
      case NMEndianLittle:
        PACK64LITTLE(uMSB, uLSB, buf);
        break;
      case NMEndianNative:
        PACK64NATIVE(uMSB, uLSB, buf);
        break;
      case NMEndianBig:
      default:
        PACK64BIG(uMSB, uLSB, buf);
        break;
    }
  }

  return (int)fvalLen;
}
/*!
 * \brief Pack an signed 64-bit integer into the message buffer.
 *
 * If the machine architecture only supports 32-bit long longs, then
 * the 4 MSBs are signed extended.
 *
 * \copydoc doc_params_pack_std
 * \copydoc doc_return_pack_std 
 */
\brief Pack an signed 64-bit integer into the message buffer.
If the machine architecture only supports 32-bit long longs, then
the 4 MSBs are signed extended.


\ brief Pack an signed 64 - bit integer into the message buffer . If the machine architecture only supports 32 - bit long longs then the 4 MSBs are signed extended .
int nmPackS64(long long val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
{
  static size_t fvalLen = NMFVAL_LEN_S64;     
  uint_t        uMSB;     
  uint_t        uLSB;     
  _NM_CHK_MEM(bufSize, fvalLen);
  if( sizeof(long long) == fvalLen )
  {
    switch( eEndian )
    {
      case NMEndianLittle:
        PACKLITTLE(val, buf);
        break;
      case NMEndianNative:
        PACKNATIVE(val, buf);
        break;
      case NMEndianBig:
      default:
        PACKBIG(val, buf);
        break;
    }
  }
  else
  {
    _NM_CHK_ARCH(val, (size_t)NMFVAL_LEN_S32);
    uMSB = val & 0x80000000? 0xffffffff: 0x00000000;  
    uLSB = (uint_t)val;
    switch( eEndian )
    {
      case NMEndianLittle:
        PACK64LITTLE(uMSB, uLSB, buf);
        break;
      case NMEndianNative:
        PACK64NATIVE(uMSB, uLSB, buf);
        break;
      case NMEndianBig:
      default:
        PACK64BIG(uMSB, uLSB, buf);
        break;
    }
  }
  return (int)fvalLen;
}
int nmPackS64 ( long long val , byte_t buf [ ] , size_t bufSize , NMEndian_T eEndian ) { static size_t fvalLen = NMFVAL_LEN_S64 ; uint_t uMSB ; uint_t uLSB ; _NM_CHK_MEM ( bufSize , fvalLen ) ; if ( sizeof ( long long ) == fvalLen ) { switch ( eEndian ) { case NMEndianLittle : PACKLITTLE ( val , buf ) ; break ; case NMEndianNative : PACKNATIVE ( val , buf ) ; break ; case NMEndianBig : default : PACKBIG ( val , buf ) ; break ; } } else { _NM_CHK_ARCH ( val , ( size_t ) NMFVAL_LEN_S32 ) ; uMSB = val & 0x80000000 ? 0xffffffff : 0x00000000 ; uLSB = ( uint_t ) val ; switch ( eEndian ) { case NMEndianLittle : PACK64LITTLE ( uMSB , uLSB , buf ) ; break ; case NMEndianNative : PACK64NATIVE ( uMSB , uLSB , buf ) ; break ; case NMEndianBig : default : PACK64BIG ( uMSB , uLSB , buf ) ; break ; } } return ( int ) fvalLen ; }
\brief Pack an signed 64-bit integer into the message buffer.
\ brief Pack an signed 64 - bit integer into the message buffer .
// message field value length // most significant bytes // least signifcant bytes // 8-byte signed long long // 4-byte signed long long // extend sign