Maneira mais rápida de mudar endianness

Qual é a maneira mais rápida de reverter a endianidade de um número inteiro de 16 e 32 bits. Eu costumo fazer algo parecido (essa codificação foi feita no Visual Studio em C ++):

union bytes4
{
    __int32 value;
    char ch[4];
};

union bytes2
{
    __int16 value;
    char ch[2];
};

__int16 changeEndianness16(__int16 val)
{
    bytes2 temp;
    temp.value=val;

    char x= temp.ch[0];
    temp.ch[0]=temp.ch[1];
    temp.ch[1]=x;
    return temp.value;
}

__int32 changeEndianness32(__int32 val)
{
    bytes4 temp;
    temp.value=val;
    char x;

    x= temp.ch[0];
    temp.ch[0]=temp.ch[1];
    temp.ch[1]=x;

    x= temp.ch[2];
    temp.ch[2]=temp.ch[3];
    temp.ch[3]=x;
    return temp.value;
}

Existe algumMais rápid maneira de fazer o mesmo, em que não preciso fazer tantos cálculo

questionAnswers(4)

yourAnswerToTheQuestion