clsync
port-hacks.h
Go to the documentation of this file.
1 /*
2  clsync - file tree sync utility based on fanotify and inotify
3 
4  Copyright (C) 2014 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __PORT_HACKS_H
21 #define __PORT_HACKS_H
22 
23 #ifndef ETIME
24 #define ETIME ETIMEDOUT
25 #endif
26 
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 
30 #if __FreeBSD__ || __FreeBSD_kernel__
31 # include <sys/syslimits.h>
32 
33 # define O_PATH 0
34 
35 # include <pthread.h>
36 
37 # ifdef THREADING_SUPPORT
38 static inline int pthread_tryjoin_np ( pthread_t thread, void **retval )
39 {
40  struct timespec abstime;
41  int rc;
42  abstime.tv_sec = 0;
43  abstime.tv_nsec = 0;
44  extern int pthread_timedjoin_np ( pthread_t thread, void **value_ptr, const struct timespec * abstime );
45  rc = pthread_timedjoin_np ( thread, retval, &abstime );
46 
47  if ( rc == ETIMEDOUT )
48  rc = EBUSY;
49 
50  return rc;
51 }
52 # endif
53 
54 # ifndef __USE_LARGEFILE64
55 typedef struct stat stat64_t;
56 static inline int lstat64 ( const char *pathname, struct stat *buf )
57 {
58  return lstat ( pathname, buf );
59 }
60 # else
61 typedef struct stat64 stat64_t;
62 # endif
63 
64 #else
65 typedef struct stat64 stat64_t;
66 #endif
67 
68 #ifdef CLSYNC_ITSELF
69 # ifndef O_PATH
70 # warning O_PATH is not set
71 # define O_PATH 0
72 # endif
73 #endif
74 
75 #endif // __PORT_HACKS_H
76 
stat64_t
struct stat64 stat64_t
Definition: port-hacks.h:65