/*
   fichier def32.h : Définit les opérations à utiliser
    pour manipuler des données 32 bits de manière portable.
   dérivé de def64.h par Yann GUIDON le 5 août 2007
   version 3 septembre 2007

   exemple de compilation :
     gcc -Os -W -Wall -momit-leaf-frame-pointer -march=pentium3 nomdufichier.c
*/

#ifndef ___DEF32_H___
#include "machine/machine.h"

#define PTR_CAST (long)

#ifndef SHIFT_WRAP32
 #define SHIFT_MASK32(i,j) ((i) & (j))
#else
 #define SHIFT_MASK32(i,j)  (i)
#endif

/* adaptation des sens de décalage */
#ifndef WORDS_BIGENDIAN
  #define LOCAL_SHL32(x,y) (x << y)
  #define LOCAL_SHR32(x,y) (x >> y)
  #define CONVERT_LE32(x)  (x)
#else
  #define LOCAL_SHL32(x,y) (x >> y)
  #define LOCAL_SHR32(x,y) (x << y)
  /* sans ({ }) pour compiler des constantes : */
  #define CONVERT_LE32(x)  ((U32) \
       ((((U32)(x) & (U32)0x000000ffUL) << 24) |\
        (((U32)(x) & (U32)0x0000ff00UL) <<  8) |\
        (((U32)(x) & (U32)0x00ff0000UL) >>  8) |\
        (((U32)(x) & (U32)0xff000000UL) >> 24) ))
#endif

#endif /* ___DEF32_H___ */
