Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2012-2013 Werner Dittmann |
| 3 | |
| 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as published by |
| 6 | the Free Software Foundation, either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef _OSSPECIFICS_H_ |
| 19 | #define _OSSPECIFICS_H_ |
| 20 | |
| 21 | /** |
| 22 | * @file osSpecifics.h |
| 23 | * @brief Some functions to adapt to OS and/or compiler specific handling |
| 24 | * @defgroup GNU_ZRTP The GNU ZRTP C++ implementation |
| 25 | * @{ |
| 26 | * |
| 27 | * This modules contains some functions that are either specific for a particular |
| 28 | * OS or use include files that are not common. |
| 29 | * |
| 30 | * This header file shall not #include system specific header files and shall also |
| 31 | * not use specific #ifdef stuff. Refer to @c osSpecifics.c for the OS specific |
| 32 | * #include, #ifdef and implementations. |
| 33 | * |
| 34 | * @author Werner Dittmann <Werner.Dittmann@t-online.de> |
| 35 | */ |
| 36 | |
| 37 | #ifndef __EXPORT |
| 38 | #if (defined _WIN32 || defined __CYGWIN__) && defined(_DLL) |
| 39 | #define __EXPORT __declspec(dllimport) |
| 40 | #define __LOCAL |
| 41 | #elif __GNUC__ >= 4 |
| 42 | #define __EXPORT __attribute__ ((visibility("default"))) |
| 43 | #define __LOCAL __attribute__ ((visibility("hidden"))) |
| 44 | #else |
| 45 | #define __EXPORT |
| 46 | #define __LOCAL |
| 47 | #endif |
| 48 | #endif |
| 49 | |
| 50 | #if defined(_WIN32) || defined(_WIN64) |
| 51 | # define snprintf _snprintf |
| 52 | #endif |
| 53 | |
| 54 | #if defined(__cplusplus) |
| 55 | extern "C" |
| 56 | { |
| 57 | #endif |
| 58 | /** |
| 59 | * Get surrent system time in milli-second. |
| 60 | * |
| 61 | * @return current time in ms. |
| 62 | */ |
| 63 | extern uint64_t zrtpGetTickCount(); |
| 64 | |
| 65 | /** |
| 66 | * Convert a 32bit variable from network to host order. |
| 67 | * |
| 68 | * Replaces the macros found in @c inet.h or @c WinSock2.h. Use this function |
| 69 | * to avoid different includes freamed with @c #idef in the sources. Including |
| 70 | * @c WinSock2 will increase compile time and may lead to other subtle problems |
| 71 | * because @c WinSock2 also includes @c windows.h. |
| 72 | * |
| 73 | * @param net 32bit variable in network byte order. |
| 74 | * |
| 75 | * @return 32bit variable in host byte order. |
| 76 | */ |
| 77 | extern uint32_t zrtpNtohl (uint32_t net); |
| 78 | |
| 79 | /** |
| 80 | * Convert a 16bit variable from network to host order. |
| 81 | * |
| 82 | * @param net 16bit variable in network byte order. |
| 83 | * |
| 84 | * @return 16bit variable in host byte order. |
| 85 | * |
| 86 | * @sa zrtpNtohl() |
| 87 | */ |
| 88 | extern uint16_t zrtpNtohs (uint16_t net); |
| 89 | |
| 90 | /** |
| 91 | * Convert a 32bit variable from host to network order. |
| 92 | * |
| 93 | * @param host 32bit variable in host byte order. |
| 94 | * |
| 95 | * @return 32bit variable in network byte order. |
| 96 | * |
| 97 | * @sa zrtpNtohl() |
| 98 | */ |
| 99 | extern uint32_t zrtpHtonl (uint32_t host); |
| 100 | |
| 101 | /** |
| 102 | * Convert a 16bit variable from host to network order. |
| 103 | * |
| 104 | * @param host 16bit variable in host byte order. |
| 105 | * |
| 106 | * @return 16bit variable in network byte order. |
| 107 | * |
| 108 | * @sa zrtpNtohl() |
| 109 | */ |
| 110 | extern uint16_t zrtpHtons (uint16_t host); |
| 111 | |
| 112 | #if defined(__cplusplus) |
| 113 | } |
| 114 | #endif |
| 115 | |
| 116 | |
| 117 | /** |
| 118 | * @} |
| 119 | */ |
| 120 | #endif |