Compile vppinfra on macOS 18/14618/3
authorDamjan Marion <damarion@cisco.com>
Mon, 3 Sep 2018 10:30:36 +0000 (12:30 +0200)
committerDamjan Marion <dmarion@me.com>
Mon, 3 Sep 2018 16:51:40 +0000 (16:51 +0000)
Add missing calls to clib_mem_init to vppinfra test codes.

Change-Id: I53ffc6fc287d1a378065bb86c18b6e995ecdb775
Signed-off-by: Damjan Marion <damarion@cisco.com>
Signed-off-by: Dave Barach <dave@barachs.net>
26 files changed:
src/CMakeLists.txt
src/vppinfra/CMakeLists.txt
src/vppinfra/elog.c
src/vppinfra/longjmp.S
src/vppinfra/mem_dlmalloc.c
src/vppinfra/socket.c
src/vppinfra/test_format.c
src/vppinfra/test_hash.c
src/vppinfra/test_longjmp.c
src/vppinfra/test_macros.c
src/vppinfra/test_maplog.c
src/vppinfra/test_phash.c
src/vppinfra/test_pool_iterate.c
src/vppinfra/test_qhash.c
src/vppinfra/test_random_isaac.c
src/vppinfra/test_serialize.c
src/vppinfra/test_socket.c
src/vppinfra/test_time.c
src/vppinfra/test_time_range.c
src/vppinfra/test_timing_wheel.c
src/vppinfra/test_vec.c
src/vppinfra/test_vhash.c
src/vppinfra/test_zvec.c
src/vppinfra/time.h
src/vppinfra/timer.c
src/vppinfra/unix-formats.c

index 11f2be9..53cb185 100644 (file)
@@ -61,7 +61,6 @@ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")
 
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
-find_package(OpenSSL REQUIRED)
 
 include(cmake/memfd.cmake)
 include(cmake/api.cmake)
@@ -72,11 +71,18 @@ include(cmake/plugin.cmake)
 ##############################################################################
 # subdirs - order matters
 ##############################################################################
-foreach(
-  DIR
-  vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins
-  vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool
-)
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+  find_package(OpenSSL REQUIRED)
+  set(SUBDIRS
+    vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins
+    vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+  set(SUBDIRS vppinfra)
+else()
+  message(FATAL_ERROR "Unsupported system: ${CMAKE_SYSTEM_NAME}")
+endif()
+
+foreach(DIR ${SUBDIRS})
   add_subdirectory(${DIR})
 endforeach()
 
index d5242e8..1e73335 100644 (file)
@@ -44,7 +44,6 @@ set(VPPINFRA_SRCS
   cpu.c
   cuckoo_template.c
   elf.c
-  elf_clib.c
   elog.c
   error.c
   fheap.c
@@ -84,8 +83,6 @@ set(VPPINFRA_SRCS
   vec.c
   vector.c
   zvec.c
-  linux/mem.c
-  linux/sysfs.c
 )
 
 set(VPPINFRA_HEADERS
@@ -181,6 +178,14 @@ set(VPPINFRA_HEADERS
   linux/sysfs.h
 )
 
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+  list(APPEND VPPINFRA_SRCS
+    elf_clib.c
+    linux/mem.c
+    linux/sysfs.c
+   )
+endif()
+
 
 if(VPP_USE_DLMALLOC)
   list(APPEND VPPINFRA_SRCS
index 182ca12..036dce9 100644 (file)
@@ -413,7 +413,11 @@ elog_time_now (elog_time_stamp_t * et)
 #ifdef CLIB_UNIX
   {
 #include <sys/syscall.h>
+#ifdef __APPLE__
+    clock_gettime (CLOCK_REALTIME, &ts);
+#else
     syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
     cpu_time_now = clib_cpu_time_now ();
     /* Subtract 3/30/2017's worth of seconds to retain precision */
     os_time_now_nsec = 1e9 * (ts.tv_sec - 1490885108) + ts.tv_nsec;
index 6468dba..0b7449f 100644 (file)
   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
-       
+
+#if defined(__APPLE__)
+# define cdecl(s) _##s
+#else
+# define cdecl(s) s
+#endif
+
 #if defined(__x86_64__)
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, @function
-clib_setjmp:
+#ifndef __APPLE__
+       .type cdecl(clib_setjmp), @function
+#endif
+
+cdecl(clib_setjmp):
        movq %rbx, 8*0(%rdi)
        movq %rbp, 8*1(%rdi)
        movq %r12, 8*2(%rdi)
@@ -59,10 +68,12 @@ clib_setjmp:
        movq %rsi, %rax
        ret
        
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, @function
-clib_longjmp:  
+#ifndef __APPLE__
+       .type cdecl(clib_longjmp), @function
+#endif
+cdecl(clib_longjmp):   
         /* Restore regs. */
        movq 8*0(%rdi), %rbx
        movq 8*1(%rdi), %rbp
@@ -79,10 +90,12 @@ clib_longjmp:
        /* Away we go. */
        jmpq *%rdx      
        
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, @function
-clib_calljmp:
+#ifndef __APPLE__
+       .type cdecl(clib_calljmp), @function
+#endif
+cdecl(clib_calljmp):
        /* Make sure stack is 16-byte aligned. */
        movq %rdx, %rax
        andq $0xf, %rax
@@ -118,10 +131,10 @@ clib_calljmp:
        jmpq *%rdx
 
 #elif defined(i386)
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, @function
-clib_setjmp:
+       .type cdecl(clib_setjmp), @function
+cdecl(clib_setjmp):
        movl 4(%esp), %ecx
        
        movl %ebp, 4*0(%ecx)
@@ -141,10 +154,10 @@ clib_setjmp:
        movl 8(%esp), %eax
        ret
        
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, @function
-clib_longjmp:  
+       .type cdecl(clib_longjmp), @function
+cdecl(clib_longjmp):   
        movl 4(%esp), %ecx
        
        /* Give back user's return value. */
@@ -161,10 +174,10 @@ clib_longjmp:
        /* Away we go. */
        jmp *%edx       
        
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, @function
-clib_calljmp:  
+       .type cdecl(clib_calljmp), @function
+cdecl(clib_calljmp):   
        /* Get new stack pointer. */
        movl 12(%esp), %edx
        
@@ -224,7 +237,7 @@ _ (26, 6) _ (27, 7) _ (28, 8) _ (29, 9) _ (30, 10) _ (31, 11)
 #define CLIB_POWERPC_ALTIVEC_N_REGS 0
 #endif
 
-_prologue (clib_setjmp)
+_prologue (cdecl(clib_setjmp))
        mflr 0
        std 0, 8*0(3)
        std 1, 8*1(3)
@@ -257,7 +270,7 @@ _prologue (clib_setjmp)
        
        blr
        
-_prologue (clib_longjmp)
+_prologue (cdecl(clib_longjmp))
        ld 0, 8*0(3)
        mtlr 0
        ld 1, 8*1(3)
@@ -290,14 +303,14 @@ _prologue (clib_longjmp)
        
        blr
 
-       .globl clib_calljmp
+       .globl cdecl(clib_calljmp)
        .section        ".opd","aw"
        .align 3
-clib_calljmp:
-       .quad   .L.clib_calljmp,.TOC.@tocbase,0
+cdecl(clib_calljmp):
+       .quad   .L.cdecl(clib_calljmp),.TOC.@tocbase,0
        .previous
-       .type   clib_calljmp, @function
-.L.clib_calljmp:
+       .type   cdecl(clib_calljmp), @function
+.L.cdecl(clib_calljmp):
        mflr 0
        mr 9,3
        std 0,16(1)
@@ -325,7 +338,7 @@ clib_calljmp:
        blr
        .long 0
        .byte 0,0,0,1,128,0,0,0
-       .size   clib_calljmp,.-.L.clib_calljmp
+       .size   cdecl(clib_calljmp),.-.L.cdecl(clib_calljmp)
        
 #elif defined(__powerpc__)
        
@@ -344,10 +357,10 @@ _ (26, 6) _ (27, 7) _ (28, 8) _ (29, 9) _ (30, 10) _ (31, 11)
 #define CLIB_POWERPC_ALTIVEC_N_REGS 0
 #endif
 
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, @function
-clib_setjmp:
+       .type cdecl(clib_setjmp), @function
+cdecl(clib_setjmp):
        mflr 0
        stw 0, 4*0(3)
        stw 1, 4*1(3)
@@ -380,10 +393,10 @@ clib_setjmp:
        
        blr
        
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, @function
-clib_longjmp:  
+       .type cdecl(clib_longjmp), @function
+cdecl(clib_longjmp):   
        
        lwz 0, 4*0(3)
        mtlr 0
@@ -417,10 +430,10 @@ clib_longjmp:
        
        blr
 
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, @function
-clib_calljmp:  
+       .type cdecl(clib_calljmp), @function
+cdecl(clib_calljmp):   
        /* Make sure stack is 16 byte aligned. */
        andi. 0, 5, 0xf
        sub  5, 5, 0
@@ -458,10 +471,10 @@ clib_calljmp:
        
 #elif defined(__arm__)
        
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, %function
-clib_setjmp:
+       .type cdecl(clib_setjmp), %function
+cdecl(clib_setjmp):
        mov ip, r0              /* jmp buffer */
 
        /* Save integer registers */
@@ -481,10 +494,10 @@ clib_setjmp:
        mov r0, r1
        bx lr
        
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, %function
-clib_longjmp:  
+       .type cdecl(clib_longjmp), %function
+cdecl(clib_longjmp):   
        mov ip, r0              /* jmp buffer */
 
        /* Restore integer registers. */
@@ -504,10 +517,10 @@ clib_longjmp:
        mov r0, r1
        bx lr
 
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, %function
-clib_calljmp:  
+       .type cdecl(clib_calljmp), %function
+cdecl(clib_calljmp):   
        /* Make sure stack is 8 byte aligned. */
        bic r2, r2, #7
        
@@ -541,51 +554,51 @@ clib_calljmp:
 #elif defined(__xtensa__)
        
        /* FIXME implement if needed. */
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, %function
-clib_setjmp:
+       .type cdecl(clib_setjmp), %function
+cdecl(clib_setjmp):
 1:     j 1b
 
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, @function
-clib_longjmp:  
+       .type cdecl(clib_longjmp), @function
+cdecl(clib_longjmp):   
 1:     j 1b
        
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, %function
-clib_calljmp:  
+       .type cdecl(clib_calljmp), %function
+cdecl(clib_calljmp):   
 1:     j 1b
        
 #elif defined(__TMS320C6X__)
        
        /* FIXME implement if needed. */
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 4
-       .type clib_setjmp, %function
-clib_setjmp:
+       .type cdecl(clib_setjmp), %function
+cdecl(clib_setjmp):
 1:     B       .S1     1b
 
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 4
-       .type clib_longjmp, @function
-clib_longjmp:  
+       .type cdecl(clib_longjmp), @function
+cdecl(clib_longjmp):   
 1:     B       .S1     1b
        
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 4
-       .type clib_calljmp, %function
-clib_calljmp:  
+       .type cdecl(clib_calljmp), %function
+cdecl(clib_calljmp):   
 1:     B       .S1     1b
        
 #elif defined(_mips) && __mips == 64
 
-       .global clib_setjmp
+       .global cdecl(clib_setjmp)
        .align 8
-       .type clib_setjmp, %function
-clib_setjmp:
+       .type cdecl(clib_setjmp), %function
+cdecl(clib_setjmp):
        sd $ra, 0($a0)
        sd $sp, 8($a0)
        sd $gp, 16($a0)
@@ -602,10 +615,10 @@ clib_setjmp:
        jr $ra
        nop
 
-       .global clib_longjmp
+       .global cdecl(clib_longjmp)
        .align 8
-       .type clib_longjmp, @function
-clib_longjmp:
+       .type cdecl(clib_longjmp), @function
+cdecl(clib_longjmp):
        move $v0, $a1
        bne $v0, $0, 1f
        nop
@@ -626,10 +639,10 @@ clib_longjmp:
        jr $ra
        nop
 
-       .global clib_calljmp
+       .global cdecl(clib_calljmp)
        .align 8
-       .type clib_calljmp, %function
-clib_calljmp:
+       .type cdecl(clib_calljmp), %function
+cdecl(clib_calljmp):
        /* Force 16 byte alignment of the new stack */
        li $t1, -16
        and $t0, $a2, $t1
@@ -693,10 +706,10 @@ clib_calljmp:
        REG_PAIR (d10, d11, 128);       \
        REG_PAIR (d12, d13, 144);       \
        REG_PAIR (d14, d15, 160);
-// int clib_setjmp (jmp_buf)
-       .global clib_setjmp
-       .type   clib_setjmp, %function
-clib_setjmp:
+// int cdecl(clib_setjmp) (jmp_buf)
+       .global cdecl(clib_setjmp)
+       .type   cdecl(clib_setjmp), %function
+cdecl(clib_setjmp):
        mov     x16, sp
 #define REG_PAIR(REG1, REG2, OFFS)     stp REG1, REG2, [x0, OFFS]
 #define REG_ONE(REG1, OFFS)            str REG1, [x0, OFFS]
@@ -706,11 +719,11 @@ clib_setjmp:
 #undef REG_ONE
        mov     x0, x1
        ret
-       .size   clib_setjmp, .-clib_setjmp
-// void clib_longjmp (jmp_buf, int) __attribute__ ((noreturn))
-       .global clib_longjmp
-       .type   clib_longjmp, %function
-clib_longjmp:
+       .size   cdecl(clib_setjmp), .-cdecl(clib_setjmp)
+// void cdecl(clib_longjmp) (jmp_buf, int) __attribute__ ((noreturn))
+       .global cdecl(clib_longjmp)
+       .type   cdecl(clib_longjmp), %function
+cdecl(clib_longjmp):
 #define REG_PAIR(REG1, REG2, OFFS)     ldp REG1, REG2, [x0, OFFS]
 #define REG_ONE(REG1, OFFS)            ldr REG1, [x0, OFFS]
        GPR_LAYOUT
@@ -723,13 +736,13 @@ clib_longjmp:
        // cinc w0, w1, eq
        // use br not ret, as ret is guaranteed to mispredict
        br      x30
-       .size   clib_longjmp, .-clib_longjmp
+       .size   cdecl(clib_longjmp), .-cdecl(clib_longjmp)
 
 
-// void clib_calljmp (x0=function, x1=arg, x2=new_stack)
-       .global clib_calljmp
-       .type   clib_calljmp, %function
-clib_calljmp:
+// void cdecl(clib_calljmp) (x0=function, x1=arg, x2=new_stack)
+       .global cdecl(clib_calljmp)
+       .type   cdecl(clib_calljmp), %function
+cdecl(clib_calljmp):
        // save fn ptr
        mov     x3, x0
        // set up fn arg
@@ -756,9 +769,11 @@ clib_calljmp:
        ldr     x30,[x4, #8]
         mov     sp, x3
        ret
-       .size   clib_calljmp, .-clib_calljmp
+       .size   cdecl(clib_calljmp), .-cdecl(clib_calljmp)
 #else
 #error "unknown machine"
 #endif 
 
+#ifndef __APPLE__
 .section .note.GNU-stack,"",%progbits
+#endif
index 4a0d032..8afb050 100644 (file)
@@ -354,7 +354,7 @@ format_mheap_trace (u8 * s, va_list * va)
          {
            if (i > 0)
              s = format (s, "%U", format_white_space, indent);
-#ifdef CLIB_UNIX
+#if defined(CLIB_UNIX) && !defined(__APPLE__)
            /* $$$$ does this actually work? */
            s =
              format (s, " %U\n", format_clib_elf_symbol_with_address,
index 87a9333..29b2a94 100644 (file)
@@ -309,12 +309,16 @@ static clib_error_t *
 default_socket_recvmsg (clib_socket_t * s, void *msg, int msglen,
                        int fds[], int num_fds)
 {
+#ifdef __linux__
   char ctl[CMSG_SPACE (sizeof (int) * num_fds) +
           CMSG_SPACE (sizeof (struct ucred))];
+  struct ucred *cr = 0;
+#else
+  char ctl[CMSG_SPACE (sizeof (int) * num_fds)];
+#endif
   struct msghdr mh = { 0 };
   struct iovec iov[1];
   ssize_t size;
-  struct ucred *cr = 0;
   struct cmsghdr *cmsg;
 
   iov[0].iov_base = msg;
@@ -340,6 +344,7 @@ default_socket_recvmsg (clib_socket_t * s, void *msg, int msglen,
     {
       if (cmsg->cmsg_level == SOL_SOCKET)
        {
+#ifdef __linux__
          if (cmsg->cmsg_type == SCM_CREDENTIALS)
            {
              cr = (struct ucred *) CMSG_DATA (cmsg);
@@ -347,7 +352,9 @@ default_socket_recvmsg (clib_socket_t * s, void *msg, int msglen,
              s->gid = cr->gid;
              s->pid = cr->pid;
            }
-         else if (cmsg->cmsg_type == SCM_RIGHTS)
+         else
+#endif
+         if (cmsg->cmsg_type == SCM_RIGHTS)
            {
              clib_memcpy (fds, CMSG_DATA (cmsg), num_fds * sizeof (int));
            }
@@ -436,6 +443,7 @@ clib_socket_init (clib_socket_t * s)
          clib_unix_warning ("setsockopt SO_REUSEADDR fails");
       }
 
+#if __linux__
       if (addr.sa.sa_family == PF_LOCAL && s->flags & CLIB_SOCKET_F_PASSCRED)
        {
          int x = 1;
@@ -447,6 +455,7 @@ clib_socket_init (clib_socket_t * s)
              goto done;
            }
        }
+#endif
 
       if (need_bind && bind (s->fd, &addr.sa, addr_len) < 0)
        {
index cc95a00..8370be7 100644 (file)
@@ -180,6 +180,8 @@ main (int argc, char *argv[])
 {
   unformat_input_t i;
 
+  clib_mem_init (0, 3ULL << 30);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
 
index 94110ab..7f047d9 100644 (file)
@@ -440,6 +440,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 3ULL << 30);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   ret = test_hash_main (&i);
index 2415c4f..01debe2 100644 (file)
@@ -112,6 +112,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int res;
 
+  clib_mem_init (0, 64 << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   res = test_longjmp_main (&i);
index 05299b3..cf6172a 100644 (file)
@@ -47,6 +47,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   ret = test_macros_main (&i);
   unformat_free (&i);
index 7ae70c5..f3ff662 100644 (file)
@@ -123,6 +123,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   ret = test_maplog_main (&i);
   unformat_free (&i);
index 9ed2ac7..47711c2 100644 (file)
@@ -132,6 +132,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int res;
 
+  clib_mem_init (0, 64ULL << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   res = test_phash_main (&i);
index 406a2a5..4e8e2df 100644 (file)
@@ -32,6 +32,8 @@ main (int argc, char *argv[])
   u32 *tp = 0;
   u32 *junk;
 
+  clib_mem_init (0, 64ULL << 20);
+
   for (i = 0; i < 70; i++)
     {
       pool_get (tp, junk);
index fdbf0bb..68e8cbc 100644 (file)
@@ -311,6 +311,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   clib_error_t *error;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   error = test_qhash_main (&i);
   unformat_free (&i);
index 337d30d..bed8673 100644 (file)
@@ -123,6 +123,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   ret = test_isaac_main (&i);
index 6351b05..09f3808 100644 (file)
@@ -258,6 +258,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int r;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   r = test_serialize_main (&i);
   unformat_free (&i);
index 2f25ecc..ea0ae65 100644 (file)
@@ -117,6 +117,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int r;
 
+  clib_mem_init (0, 64ULL << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   r = test_socket_main (&i);
index 63cfeac..80c0e3a 100644 (file)
@@ -86,6 +86,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   ret = test_time_main (&i);
index ccb63b2..2ec6e13 100644 (file)
@@ -162,6 +162,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   ret = test_time_range_main (&i);
   unformat_free (&i);
index 0ce15ad..7cf6e0c 100644 (file)
@@ -367,6 +367,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   clib_error_t *error;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   error = test_timing_wheel_main (&i);
   unformat_free (&i);
index d60d27b..d02d71c 100644 (file)
@@ -1173,8 +1173,6 @@ main (int argc, char *argv[])
 
   clib_mem_init (0, 3ULL << 30);
 
-  //  mheap_alloc (0, (uword) 10ULL << 30);
-
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   ret = test_vec_main (&i);
index 7293fdd..f5aa5e2 100644 (file)
@@ -741,6 +741,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int r;
 
+  clib_mem_init (0, 64ULL << 20);
+
   unformat_init_command_line (&i, argv);
   r = test_vhash_main (&i);
   unformat_free (&i);
index 874fdef..7d777fa 100644 (file)
@@ -98,6 +98,8 @@ main (int argc, char *argv[])
   unformat_input_t i;
   int ret;
 
+  clib_mem_init (0, 64ULL << 20);
+
   verbose = (argc > 1);
   unformat_init_command_line (&i, argv);
   ret = test_zvec_main (&i);
index ced9677..64370d5 100644 (file)
@@ -237,10 +237,14 @@ void clib_time_init (clib_time_t * c);
 always_inline f64
 unix_time_now (void)
 {
+  struct timespec ts;
+#ifdef __MACH__
+  clock_gettime (CLOCK_REALTIME, &ts);
+#else
   /* clock_gettime without indirect syscall uses GLIBC wrappers which
      we don't want.  Just the bare metal, please. */
-  struct timespec ts;
   syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
   return ts.tv_sec + 1e-9 * ts.tv_nsec;
 }
 
@@ -249,7 +253,11 @@ always_inline u64
 unix_time_now_nsec (void)
 {
   struct timespec ts;
+#ifdef __MACH__
+  clock_gettime (CLOCK_REALTIME, &ts);
+#else
   syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
   return 1e9 * ts.tv_sec + ts.tv_nsec;
 }
 
@@ -257,7 +265,11 @@ always_inline void
 unix_time_now_nsec_fraction (u32 * sec, u32 * nsec)
 {
   struct timespec ts;
+#ifdef __MACH__
+  clock_gettime (CLOCK_REALTIME, &ts);
+#else
   syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
   *sec = ts.tv_sec;
   *nsec = ts.tv_nsec;
 }
index 85149dc..8bbab65 100644 (file)
 #include <vppinfra/timer.h>
 #include <vppinfra/error.h>
 
+#ifndef HZ
+#define HZ 1000
+#endif
+
 typedef struct
 {
   f64 time;
@@ -112,14 +116,14 @@ timer_interrupt (int signum)
          vector of pending timers. */
       t = vec_end (timers) - 1;
 
-      ASSERT (now >= 0 && finite (now));
+      ASSERT (now >= 0 && isfinite (now));
 
       /* Time difference between when timer goes off and now. */
       dt = t->time - now;
 
       /* If timer is within threshold of going off
          call user's callback. */
-      if (dt <= time_resolution && finite (dt))
+      if (dt <= time_resolution && isfinite (dt))
        {
          _vec_len (timers) -= 1;
          (*t->func) (t->arg, -dt);
index b3b8c89..c447329 100644 (file)
 
 #ifdef __KERNEL__
 
+#if __linux__
 # include <linux/unistd.h>
 # include <linux/signal.h>
+#endif
 
 #else /* ! __KERNEL__ */
 
+#ifdef __APPLE__
+#define _XOPEN_SOURCE
+#endif
+
 #define _GNU_SOURCE            /* to get REG_* in ucontext.h */
 #include <ucontext.h>
 #undef _GNU_SOURCE
 #include <math.h>
 
 #include <vppinfra/time.h>
+#if __linux__
 #include <vppinfra/linux/syscall.h>
 
 #ifdef AF_NETLINK
 #include <linux/types.h>
 #include <linux/netlink.h>
 #endif
+#endif
 
 #endif /* ! __KERNEL__ */
 
@@ -277,6 +285,7 @@ u8 * format_sockaddr (u8 * s, va_list * args)
   return s;
 }
 
+#ifndef __APPLE__
 u8 * format_tcp4_packet (u8 * s, va_list * args)
 {
   u8 * p = va_arg (*args, u8 *);
@@ -832,6 +841,7 @@ u8 * format_timeval (u8 * s, va_list * args)
 
   return s;
 }
+#endif
 
 u8 * format_time_float (u8 * s, va_list * args)
 {