comparison dbutil.c @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 4afde04f0607 2d450c1056e3
children 2f64cb3d3007
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
219 va_end(param); 219 va_end(param);
220 } 220 }
221 #endif /* DEBUG_TRACE */ 221 #endif /* DEBUG_TRACE */
222 222
223 /* Connect to a given unix socket. The socket is blocking */ 223 /* Connect to a given unix socket. The socket is blocking */
224 #ifdef ENABLE_CONNECT_UNIX 224 #if ENABLE_CONNECT_UNIX
225 int connect_unix(const char* path) { 225 int connect_unix(const char* path) {
226 struct sockaddr_un addr; 226 struct sockaddr_un addr;
227 int fd = -1; 227 int fd = -1;
228 228
229 memset((void*)&addr, 0x0, sizeof(addr)); 229 memset((void*)&addr, 0x0, sizeof(addr));
246 /* Sets up a pipe for a, returning three non-blocking file descriptors 246 /* Sets up a pipe for a, returning three non-blocking file descriptors
247 * and the pid. exec_fn is the function that will actually execute the child process, 247 * and the pid. exec_fn is the function that will actually execute the child process,
248 * it will be run after the child has fork()ed, and is passed exec_data. 248 * it will be run after the child has fork()ed, and is passed exec_data.
249 * If ret_errfd == NULL then stderr will not be captured. 249 * If ret_errfd == NULL then stderr will not be captured.
250 * ret_pid can be passed as NULL to discard the pid. */ 250 * ret_pid can be passed as NULL to discard the pid. */
251 int spawn_command(void(*exec_fn)(void *user_data), void *exec_data, 251 int spawn_command(void(*exec_fn)(const void *user_data), const void *exec_data,
252 int *ret_writefd, int *ret_readfd, int *ret_errfd, pid_t *ret_pid) { 252 int *ret_writefd, int *ret_readfd, int *ret_errfd, pid_t *ret_pid) {
253 int infds[2]; 253 int infds[2];
254 int outfds[2]; 254 int outfds[2];
255 int errfds[2]; 255 int errfds[2];
256 pid_t pid; 256 pid_t pid;
609 /* CLOCK_MONOTONIC_COARSE was added in Linux 2.6.32 but took a while to 609 /* CLOCK_MONOTONIC_COARSE was added in Linux 2.6.32 but took a while to
610 reach userspace include headers */ 610 reach userspace include headers */
611 #ifndef CLOCK_MONOTONIC_COARSE 611 #ifndef CLOCK_MONOTONIC_COARSE
612 #define CLOCK_MONOTONIC_COARSE 6 612 #define CLOCK_MONOTONIC_COARSE 6
613 #endif 613 #endif
614 /* Some old toolchains know SYS_clock_gettime but not CLOCK_MONOTONIC */
615 #ifndef CLOCK_MONOTONIC
616 #define CLOCK_MONOTONIC 1
617 #endif
614 static clockid_t get_linux_clock_source() { 618 static clockid_t get_linux_clock_source() {
615 struct timespec ts; 619 struct timespec ts;
616 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, &ts) == 0) { 620 if (syscall(SYS_clock_gettime, CLOCK_MONOTONIC_COARSE, &ts) == 0) {
617 return CLOCK_MONOTONIC_COARSE; 621 return CLOCK_MONOTONIC_COARSE;
618 } 622 }