Browse Source

Defining android causes android to fail building, defining android=android makes Defined macro not work.

Caleb James DeLisle 1 year ago
parent
commit
9e8ea4cbfd

+ 4 - 4
client/cjdroute2.c

@@ -356,7 +356,7 @@ static int genconf(struct Allocator* alloc, struct Random* rand, bool eth, bool
            "        // and ETHInterface will be unable to hot-add new interfaces\n"
            "        // Use { \"setuser\": 0 } to disable.\n"
            "        // Default: enabled with keepNetAdmin\n");
-           if (Defined(android) || Defined(darwin)) {
+           if (Defined(Cjdns_android) || Defined(darwin)) {
     printf("        { \"setuser\": 0 },\n");
            } else {
     printf("        { \"setuser\": \"nobody\", \"keepNetAdmin\": 1 },\n");
@@ -366,7 +366,7 @@ static int genconf(struct Allocator* alloc, struct Random* rand, bool eth, bool
            "        // from accessing files outside of the chroot sandbox, if the user does not\n"
            "        // have permission to use chroot(), this will fail quietly.\n"
            "        // Use { \"chroot\": 0 } to disable.\n");
-          if (Defined(android)) {
+          if (Defined(Cjdns_android)) {
     printf("        // Default: disabled\n"
            "        { \"chroot\": 0 },\n");
           }
@@ -391,7 +391,7 @@ static int genconf(struct Allocator* alloc, struct Random* rand, bool eth, bool
            "        // SECCOMP_BPF to filter the system calls which cjdns is able to make on a\n"
            "        // linux system, strictly limiting it's access to the outside world\n"
            "        // This will fail quietly on any non-linux system\n");
-          if (Defined(android)) {
+          if (Defined(Cjdns_android)) {
     printf("        // Default: disabled\n"
            "        { \"seccomp\": 0 },\n");
           }
@@ -578,7 +578,7 @@ static String* getPipePath(Dict* config, struct Allocator* alloc)
         return pipePath;
     }
     char* path = Pipe_PATH;
-    if (Defined(android)) {
+    if (Defined(Cjdns_android)) {
         char* t = getenv("TMPDIR");
         if (!t) {
             t = getenv("HOME");

+ 2 - 2
interface/ETHInterface_linux.c

@@ -39,7 +39,7 @@
 #include <unistd.h>
 #include <errno.h>
 
-#ifndef android
+#ifndef Cjdns_android
     #include <ifaddrs.h>
 #endif
 
@@ -207,7 +207,7 @@ static void handleEvent(void* vcontext)
 Er_DEFUN(List* ETHInterface_listDevices(struct Allocator* alloc))
 {
     List* out = List_new(alloc);
-#ifndef android
+#ifndef Cjdns_android
     struct ifaddrs* ifaddr = NULL;
     if (getifaddrs(&ifaddr) || ifaddr == NULL) {
         Er_raise(alloc, "getifaddrs() -> errno:%d [%s]", errno, strerror(errno));

+ 1 - 1
interface/tuntap/TUNInterface_linux.c

@@ -35,7 +35,7 @@
 #include <linux/if_ether.h>
 #include <net/if.h>
 
-#if defined(android)
+#if defined(Cjdns_android)
   #define DEVICE_PATH "/dev/tun"
 #else
   #define DEVICE_PATH "/dev/net/tun"

+ 1 - 1
interface/tuntap/TUNMessageType.h

@@ -46,7 +46,7 @@ enum TUNMessageType {
 
 static inline enum TUNMessageType TUNMessageType_guess()
 {
-    if (Defined(android) || Defined(sunos)) {
+    if (Defined(Cjdns_android) || Defined(sunos)) {
         return TUNMessageType_NONE;
     } else if (Defined(linux) || Defined(win32)) {
         return TUNMessageType_ETHERTYPE;

+ 1 - 1
node_build/make.js

@@ -169,7 +169,7 @@ Builder.configure({
 
     if (android) {
         // NDK uses the word `android` in places
-        builder.config.cflags.push('-Dandroid=android');
+        builder.config.cflags.push('-DCjdns_android=1');
     }
 
     var uclibc = process.env['UCLIBC'] == '1';

+ 3 - 0
util/Defined.h

@@ -24,6 +24,9 @@
  * if (Defined(linux)) {
  *     doLinuxSpecificStuff();
  * }
+ * 
+ * CAUTION: Because of limitations of detection, if you `#define X X` then
+ * Defined(X) will be false!
  */
 #define Defined(macro) \
     Js_or({ return ( Js_Q macro Js_Q === ' ' + #macro + ' ' ) ? '0' : '1'; }, 1)

+ 1 - 1
util/Seccomp_linux.c

@@ -359,7 +359,7 @@ static Er_DEFUN(struct sock_fprog* mkFilter(struct Allocator* alloc))
         IFEQ(__NR_accept4, success),
         #endif
 
-        #ifdef android
+        #ifdef Cjdns_android
             #ifdef __NR_rt_sigprocmask
             IFEQ(__NR_rt_sigprocmask, success),
             #endif

+ 1 - 1
util/events/Pipe.h

@@ -53,7 +53,7 @@ struct Pipe
 #ifndef Pipe_PATH
     #ifdef win32
         #define Pipe_PATH "\\\\.\\pipe"
-    #elif defined(android)
+    #elif defined(Cjdns_android)
         #define Pipe_PATH "/data/local/tmp"
     #else
         #define Pipe_PATH "/tmp"

+ 1 - 1
util/platform/netdev/NetPlatform_linux.c

@@ -35,7 +35,7 @@
 #include <arpa/inet.h>
 #include <linux/if.h>
 #include <linux/route.h>
-#if ! defined(android)
+#if ! defined(Cjdns_android)
     #include <linux/ipv6_route.h>
 #endif
 #include <linux/netlink.h>