-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystem_util.h
50 lines (33 loc) · 1.11 KB
/
system_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* system_util.h
*
* Created on: 2011-10-14
* Author: Administrator
*/
#ifndef SYSTEM_UTIL_H_
#define SYSTEM_UTIL_H_
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <time.h>
namespace xlnet
{
#define error_exit(num,fmt,args...) \
do{ fprintf(stderr,"%ld,%s:%d,%d:%s," fmt "\n",time(NULL),__FILE__,__LINE__,errno,strerror(errno),##args);exit(num);} while(0)
#define error_return(num,fmt,args...) \
do{ fprintf(stderr,"%ld,%s:%d,%d:%s," fmt "\n",time(NULL),__FILE__,__LINE__,errno,strerror(errno),##args);return(num);} while(0)
#ifdef NDEBUG
#define debug_format(fmt,args...)
#else
#define debug_format(fmt,args...) \
do{fprintf(stdout,"%ld,%s:%d," fmt "\n",time(NULL),__FILE__,__LINE__,##args);}while(0)
#endif
int set_open_file_limit(int maxsize) ;
int get_open_file_limit() ;
int lock_file(const char* filename) ;
void set_process_title(int argc,char* argv[],const char* fmt, ...) ;
int set_thread_title(const char* fmt, ...) ;
int daemon_init(int nochdir,int noclose) ;
}
#endif /* SYSTEM_UTIL_H_ */