• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/omcproxy/src/omcproxy.h

  1 /*
  2  * Author: Steven Barth <steven at midlink.org>
  3  *
  4  * Copyright 2015 Deutsche Telekom AG
  5  *
  6  * Licensed under the Apache License, Version 2.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at
  9  *
 10  *  http://www.apache.org/licenses/LICENSE-2.0
 11  *
 12  * Unless required by applicable law or agreed to in writing, software
 13  * distributed under the License is distributed on an "AS IS" BASIS,
 14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  * See the License for the specific language governing permissions and
 16  * limitations under the License.
 17  *
 18  */
 19 
 20 #ifndef OMGPROXY_H_
 21 #define OMGPROXY_H_
 22 
 23 #ifdef __APPLE__
 24 
 25 #define __APPLE_USE_RFC_3542
 26 #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
 27 #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
 28 
 29 #include <sys/queue.h>
 30 #ifdef LIST_HEAD
 31 #undef LIST_HEAD
 32 #endif /* LIST_HEAD */
 33 
 34 #endif /* __APPLE__ */
 35 
 36 #include <stddef.h>
 37 #include <stdint.h>
 38 #include <time.h>
 39 #include <syslog.h>
 40 #include <sys/types.h>
 41 #include <libubox/utils.h>
 42 
 43 #define STR_EXPAND(tok) #tok
 44 #define STR(tok) STR_EXPAND(tok)
 45 
 46 typedef int64_t omgp_time_t;
 47 #define OMGP_TIME_MAX INT64_MAX
 48 #define OMGP_TIME_PER_SECOND INT64_C(1000)
 49 
 50 static inline omgp_time_t omgp_time(void) {
 51         struct timespec ts;
 52         clock_gettime(CLOCK_MONOTONIC, &ts);
 53         return ((omgp_time_t)ts.tv_sec * OMGP_TIME_PER_SECOND) +
 54                         ((omgp_time_t)ts.tv_nsec / (1000000000 / OMGP_TIME_PER_SECOND));
 55 }
 56 
 57 // Logging macros
 58 #ifndef L_LEVEL
 59 #define L_LEVEL LOG_WARNING
 60 #endif /* !L_LEVEL */
 61 
 62 #define L_INTERNAL(level, ...) syslog(level, __VA_ARGS__);
 63 
 64 #define L_ERR(...) L_INTERNAL(LOG_ERR, __VA_ARGS__)
 65 #define L_WARN(...) L_INTERNAL(LOG_WARNING, __VA_ARGS__)
 66 #define L_NOTICE(...) L_INTERNAL(LOG_NOTICE, __VA_ARGS__)
 67 #define L_INFO(...) L_INTERNAL(LOG_INFO, __VA_ARGS__)
 68 #define L_DEBUG(...) L_INTERNAL(LOG_DEBUG, __VA_ARGS__)
 69 
 70 // Some C99 compatibility
 71 #ifndef typeof
 72 #define typeof __typeof
 73 #endif
 74 
 75 #ifndef container_of
 76 #define container_of(ptr, type, member) (           \
 77     (type *)( (char *)ptr - offsetof(type,member) ))
 78 #endif
 79 
 80 #ifndef __unused
 81 #define __unused __attribute__((unused))
 82 #endif
 83 
 84 #endif /* PIMBD_H_ */
 85 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt