* Explain that SCMP32 comes from RFC 3561 and is easy to implement

using 2's complement arithmetic. Unfortunately C only defines
  unsigned arithmetic and consequently machines that don't use 2's
  complement (i.e unknown arithmetic) will have to be dealt with on a
  per machine basis.
This commit is contained in:
bg- 2007-04-24 16:37:45 +00:00
parent 42fe071745
commit 8b1cd7a470

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: uaodv.c,v 1.9 2007/04/24 16:08:10 bg- Exp $ * $Id: uaodv.c,v 1.10 2007/04/24 16:37:45 bg- Exp $
*/ */
/** /**
@ -56,15 +56,15 @@ PROCESS(uaodv_process, "uAODV");
static struct uip_udp_conn *aodvconn, *unicastconn; static struct uip_udp_conn *aodvconn, *unicastconn;
/* Compare sequence numbers. */ /* Compare sequence numbers as per RFC 3561. */
#ifdef __GNUC__ #ifdef __GNUC__
#define SCMP32(a, b) ((int32_t)((a) - (b))) #define SCMP32(a, b) ((int32_t)((a) - (b)))
#else /* __GNUC__ */ #else /* __GNUC__ */
/* SCMP32() seems to be called with arguments of type u32_t. /*
* These seem to be subtracted in an unsigned manner and then * The macro above works for any compiler that does int32_t arithmetic
* the result is afterwards(!) casted to a signed type. As I'm * in 2's complement. Machines that does not use 2's complement needs
* unable to detect the behaviour intended here I'm unable to * to figure a different implementation.
* port it cleanly to other compilers :-( - Oliver Schmidt */ */
#define SCMP32(a, b) exit(1) #define SCMP32(a, b) exit(1)
#endif /* __GNUC__ */ #endif /* __GNUC__ */