| util_int.h | util_int.h | |||
|---|---|---|---|---|
| skipping to change at line 23 | skipping to change at line 23 | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU Lesser General Public License for more details. | * GNU Lesser General Public License for more details. | |||
| * | * | |||
| * You should have received a copy of the GNU Lesser General Public License | * You should have received a copy of the GNU Lesser General Public License | |||
| * along with libqb. If not, see <http://www.gnu.org/licenses/>. | * along with libqb. If not, see <http://www.gnu.org/licenses/>. | |||
| */ | */ | |||
| #ifndef QB_UTIL_INT_H_DEFINED | #ifndef QB_UTIL_INT_H_DEFINED | |||
| #define QB_UTIL_INT_H_DEFINED | #define QB_UTIL_INT_H_DEFINED | |||
| #include <syslog.h> | #include "os_base.h" | |||
| #include <qb/qblog.h> | ||||
| #define qb_util_log(severity, args...) \ | #if !defined (va_copy) | |||
| do { \ | #if defined (__va_copy) | |||
| _qb_util_log (__FILE__, __LINE__, severity, ##args); \ | #define va_copy(_a, _b) __va_copy(_a, _b) | |||
| } while(0) | #else | |||
| #define va_copy(_a, _b) memcpy(&_a, &_b, sizeof(va_list)) | ||||
| void _qb_util_log(const char *file_name, | #endif /* !__va_copy */ | |||
| int32_t file_line, | #endif /* !va_copy */ | |||
| int32_t severity, | ||||
| const char *format, | /** | |||
| ...) __attribute__ ((format(printf, 4, 5))); | * This is used internally by libqb. | |||
| * | ||||
| * It sets the 32nd bit of the tags so that internal logs can be | ||||
| * destinguished from external ones. | ||||
| */ | ||||
| #ifndef S_SPLINT_S | ||||
| #define qb_util_log(priority, fmt, args...) qb_logt(priority, QB_LOG_TAG_LI | ||||
| BQB_MSG, fmt, ##args) | ||||
| #else | ||||
| #define qb_util_log | ||||
| #endif | ||||
| #ifndef S_SPLINT_S | ||||
| #define qb_util_perror(priority, fmt, args...) do { \ | ||||
| char _perr_buf_[QB_LOG_STRERROR_MAX_LEN]; \ | ||||
| const char *_perr_str_ = qb_strerror_r(errno, _perr_buf_, sizeof(_pe | ||||
| rr_buf_)); \ | ||||
| qb_logt(priority, QB_LOG_TAG_LIBQB_MSG, fmt ": %s (%d)", ##args, _pe | ||||
| rr_str_, errno); \ | ||||
| } while(0) | ||||
| #else | ||||
| #define qb_util_perror | ||||
| #endif | ||||
| /** | /** | |||
| * Create a file to be used to back shared memory. | * Create a file to be used to back shared memory. | |||
| * | * | |||
| * @param path (out) the final absolute path of the file. | * @param path (out) the final absolute path of the file. | |||
| * @param file (in) the name of the file to be used. | * @param file (in) the name of the file to be used. | |||
| * @param bytes the size to truncate the file to. | * @param bytes the size to truncate the file to. | |||
| * @param file_flags same as passed into open() | * @param file_flags same as passed into open() | |||
| * @return 0 (success) or -errno | * @return 0 (success) or -errno | |||
| */ | */ | |||
| int32_t qb_util_mmap_file_open(char *path, const char *file, size_t bytes, | int32_t qb_sys_mmap_file_open(char *path, const char *file, size_t bytes, | |||
| uint32_t file_flags); | uint32_t file_flags); | |||
| /** | /** | |||
| * Create a shared mamory circular buffer. | * Create a shared mamory circular buffer. | |||
| * | * | |||
| * @param fd an open file to use to back the shared memory. | * @param fd an open file to use to back the shared memory. | |||
| * @param buf (out) the pointer to the start of the memory. | * @param buf (out) the pointer to the start of the memory. | |||
| * @param bytes the size of the shared memory. | * @param bytes the size of the shared memory. | |||
| * @return 0 (success) or -errno | * @return 0 (success) or -errno | |||
| */ | */ | |||
| int32_t qb_util_circular_mmap(int32_t fd, void **buf, size_t bytes); | int32_t qb_sys_circular_mmap(int32_t fd, void **buf, size_t bytes); | |||
| /** | /** | |||
| * Set O_NONBLOCK and FD_CLOEXEC on a file descriptor. | * Set O_NONBLOCK and FD_CLOEXEC on a file descriptor. | |||
| * @param fd the file descriptor. | * @param fd the file descriptor. | |||
| * @return 0 (success) or -errno | * @return 0 (success) or -errno | |||
| */ | */ | |||
| int32_t qb_util_fd_nonblock_cloexec_set(int32_t fd); | int32_t qb_sys_fd_nonblock_cloexec_set(int32_t fd); | |||
| #ifndef HAVE_STRCHRNUL | ||||
| #define strchrnul(s, c_in) qb_sys_strchrnul(s, c_in) | ||||
| char * qb_sys_strchrnul(const char *s, int c_in); | ||||
| #endif /* !HAVE_STRCHRNUL */ | ||||
| #endif /* QB_UTIL_INT_H_DEFINED */ | #endif /* QB_UTIL_INT_H_DEFINED */ | |||
| End of changes. 6 change blocks. | ||||
| 14 lines changed or deleted | 41 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ | ||||