xref: /haiku/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.h (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
1 /*
2  * compat.h - Tweaks for compatibility with non-Linux systems.
3  *
4  * Copyright (c) 2002 Richard Russon
5  * Copyright (c) 2002-2004 Anton Altaparmakov
6  * Copyright (c) 2008-2009 Szabolcs Szakacsits
7  * Copyright (c) 2019      Jean-Pierre Andre
8  *
9  * This program/include file is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as published
11  * by the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program/include file is distributed in the hope that it will be
15  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program (in the main directory of the NTFS-3G
21  * distribution in the file COPYING); if not, write to the Free Software
22  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  */
24 
25 #ifndef _NTFS_COMPAT_H
26 #define _NTFS_COMPAT_H
27 
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 #ifdef HAVE_SYS_PARAM_H
32 #include <sys/param.h>
33 #endif
34 
35 #include <errno.h>	/* ENODATA */
36 
37 #ifndef ENODATA
38 #define ENODATA ENOENT
39 #endif
40 
41 #ifndef ELIBBAD
42 #define ELIBBAD ENOEXEC
43 #endif
44 
45 #ifndef ELIBACC
46 #define ELIBACC ENOENT
47 #endif
48 
49 /* xattr APIs in macOS differs from Linux ones in that they expect the special
50  * error code ENOATTR to be returned when an attribute cannot be found. So
51  * define NTFS_NOXATTR_ERRNO to the appropriate "no xattr found" errno value for
52  * the platform. */
53 #if defined(__APPLE__) || defined(__DARWIN__)
54 #define NTFS_NOXATTR_ERRNO ENOATTR
55 #else
56 #define NTFS_NOXATTR_ERRNO ENODATA
57 #endif
58 
59 #ifndef PATH_MAX
60 #define PATH_MAX 4096
61 #endif
62 
63 #ifndef HAVE_FFS
64 extern int ffs(int i);
65 #endif /* HAVE_FFS */
66 
67 #ifndef HAVE_DAEMON
68 extern int daemon(int nochdir, int noclose);
69 #endif /* HAVE_DAEMON */
70 
71 #ifndef HAVE_STRSEP
72 extern char *strsep(char **stringp, const char *delim);
73 #endif /* HAVE_STRSEP */
74 
75 #ifdef WINDOWS
76 
77 #define HAVE_STDIO_H		/* mimic config.h */
78 #define HAVE_STDARG_H
79 
80 #define atoll			_atoi64
81 #define fdatasync		commit
82 #define __inline__		inline
83 #define __attribute__(X)	/*nothing*/
84 
85 #else /* !defined WINDOWS */
86 
87 #ifndef O_BINARY
88 #define O_BINARY		0		/* unix is binary by default */
89 #endif
90 
91 #endif /* defined WINDOWS */
92 
93 #endif /* defined _NTFS_COMPAT_H */
94 
95