uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp

Modified Android.mk to define cflag "USER_MODE_LINUX" if
TARGET_USER_MODE_LINUX := true in BoardCofig.mk.
Modified set_mmap_rnd_bits_action to return 0 if "USER_MODE_LINUX" is
defined. This is needed since uml does not support the mmap_rnd_bits
sysctl, and init would otherwise crash without this check.

Test: manual

Bug: 32523022
Change-Id: I409ef64a1fa253bfb3f9fb59d0267be159819bb8
Signed-off-by: Quang Luong <qal@google.com>
diff --git a/init/Android.mk b/init/Android.mk
index 6cd47f4..325614e 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -30,6 +30,10 @@
 
 init_options += -DLOG_UEVENTS=0
 
+ifeq ($(TARGET_USER_MODE_LINUX), true)
+    init_cflags += -DUSER_MODE_LINUX
+endif
+
 init_cflags += \
     $(init_options) \
     -Wall -Wextra \
diff --git a/init/init.cpp b/init/init.cpp
index 0562dad..ec43cb4 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -379,7 +379,10 @@
     int ret = -1;
 
     /* values are arch-dependent */
-#if defined(__aarch64__)
+#if defined(USER_MODE_LINUX)
+    /* uml does not support mmap_rnd_bits */
+    ret = 0;
+#elif defined(__aarch64__)
     /* arm64 supports 18 - 33 bits depending on pagesize and VA_SIZE */
     if (set_mmap_rnd_bits_min(33, 24, false)
             && set_mmap_rnd_bits_min(16, 16, true)) {