Ignore:
Timestamp:
Mar 29, 2017 5:07:47 AM (7 years ago)
Author:
riza
Message:

Fix #2006: Fix android build failed using NDK r14 caused by by the removal of android_alarm.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/os_timestamp_posix.c

    r5501 r5574  
    164164 
    165165#include <errno.h> 
    166 #include <linux/android_alarm.h> 
    167 #include <fcntl.h> 
    168166#include <time.h> 
    169167 
     168#if defined(PJ_HAS_ANDROID_ALARM_H) && PJ_HAS_ANDROID_ALARM_H != 0 
     169#  include <linux/android_alarm.h> 
     170#  include <fcntl.h> 
     171#endif 
     172 
    170173#define NSEC_PER_SEC    1000000000 
    171174 
     175#if defined(ANDROID_ALARM_GET_TIME) 
    172176static int s_alarm_fd = -1; 
    173177 
     
    178182    s_alarm_fd = -1; 
    179183} 
     184#endif 
    180185 
    181186PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) 
     
    184189    int err = -1; 
    185190 
     191#if defined(ANDROID_ALARM_GET_TIME) 
    186192    if (s_alarm_fd == -1) { 
    187193        int fd = open("/dev/alarm", O_RDONLY); 
     
    196202              ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &tp); 
    197203    } 
     204#elif defined(CLOCK_BOOTTIME) 
     205    err = clock_gettime(CLOCK_BOOTTIME, &tp); 
     206#endif 
    198207     
    199208    if (err != 0) { 
    200209        /* Fallback to CLOCK_MONOTONIC if /dev/alarm is not found, or 
    201          * getting ANDROID_ALARM_ELAPSED_REALTIME fails. 
     210         * getting ANDROID_ALARM_ELAPSED_REALTIME fails, or  
     211         * CLOCK_BOOTTIME fails. 
    202212         */ 
    203213        err = clock_gettime(CLOCK_MONOTONIC, &tp); 
Note: See TracChangeset for help on using the changeset viewer.