Fixed Random Function calls as per random func availability for avr and arm boards.
Change-Id: I2d4e9aea56d35dd5a8112f1ec90b1215dbc728be
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4383
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
#ifdef ARDUINO
#include "Arduino.h"
+// ARM GCC compiler doesnt define srandom function.
+#if defined(ARDUINO) && !defined(ARDUINO_ARCH_SAM)
+#define HAVE_SRANDOM 1
+#endif
+
uint8_t GetRandomBitRaw()
{
return analogRead((uint8_t)ANALOG_IN) & 0x1;
{
result += result + GetRandomBit();
}
+#if HAVE_SRANDOM
srandom(result);
+#else
+ srand(result);
+#endif
return 0;
#endif
#if defined(__ANDROID__) || defined(__linux__) || defined(__APPLE__)
return rand() & 0x00FF;
#elif defined ARDUINO
+#ifdef HAVE_SRANDOM
return random() & 0x00FF;
+#else
+ return rand() & 0x00FF;
+#endif
#endif
}