ObjFW  Check-in [f39368efd8]

Overview
Comment:Fix compilation on FreeBSD
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f39368efd826e159a52a890e61c9bee6aca2801016b4f4c2a0011347e250eeb9
User & Date: js on 2019-12-09 00:49:12
Other Links: manifest | tags
Context
2019-12-09
23:08
runtime: Increase the library major version check-in: d99139b41d user: js tags: trunk
00:49
Fix compilation on FreeBSD check-in: f39368efd8 user: js tags: trunk
2019-12-08
21:51
runtime: Make methods opaque and provide an API check-in: f310bcc3ff user: js tags: trunk
Changes

Modified configure.ac from [1b627d1cea] to [5044e32c21].

1184
1185
1186
1187
1188
1189
1190

1191
1192
1193
1194
1195
1196
1197
		msdosdjgpp*)
			dnl DJGPP has the type, but it's not really usable.
			;;
		*)
			AC_CHECK_TYPE(off64_t, [
				AC_DEFINE(OF_HAVE_OFF64_T, 1,
					[Whether we have off64_t])

			])
			;;
	esac

	AC_CHECK_HEADERS([pwd.h grp.h])
	AC_CHECK_FUNC(chmod, [
		AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()])







>







1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
		msdosdjgpp*)
			dnl DJGPP has the type, but it's not really usable.
			;;
		*)
			AC_CHECK_TYPE(off64_t, [
				AC_DEFINE(OF_HAVE_OFF64_T, 1,
					[Whether we have off64_t])
				AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64])
			])
			;;
	esac

	AC_CHECK_HEADERS([pwd.h grp.h])
	AC_CHECK_FUNC(chmod, [
		AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()])

Modified src/OFFile.m from [e53f8eae67] to [7066f87c86].

219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
			@throw [OFInvalidArgumentException exception];

		flags |= O_BINARY | O_CLOEXEC;

# if defined(OF_WINDOWS)
		if ((handle = _wopen(path.UTF16String, flags,
		    _S_IREAD | _S_IWRITE)) == -1)
# elif defined(OF_HAVE_OFF64_T)
		if ((handle = open64([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# else
		if ((handle = open([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# endif
			@throw [OFOpenItemFailedException







|







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
			@throw [OFInvalidArgumentException exception];

		flags |= O_BINARY | O_CLOEXEC;

# if defined(OF_WINDOWS)
		if ((handle = _wopen(path.UTF16String, flags,
		    _S_IREAD | _S_IWRITE)) == -1)
# elif defined(HAVE_OPEN64)
		if ((handle = open64([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# else
		if ((handle = open([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# endif
			@throw [OFOpenItemFailedException
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476

	if (_handle == OF_INVALID_FILE_HANDLE)
		@throw [OFNotOpenException exceptionWithObject: self];

#ifndef OF_AMIGAOS
# if defined(OF_WINDOWS)
	ret = _lseeki64(_handle, offset, whence);
# elif defined(OF_HAVE_OFF64_T)
	ret = lseek64(_handle, offset, whence);
# else
	ret = lseek(_handle, offset, whence);
# endif

	if (ret == -1)
		@throw [OFSeekFailedException exceptionWithStream: self







|







462
463
464
465
466
467
468
469
470
471
472
473
474
475
476

	if (_handle == OF_INVALID_FILE_HANDLE)
		@throw [OFNotOpenException exceptionWithObject: self];

#ifndef OF_AMIGAOS
# if defined(OF_WINDOWS)
	ret = _lseeki64(_handle, offset, whence);
# elif defined(HAVE_LSEEK64)
	ret = lseek64(_handle, offset, whence);
# else
	ret = lseek(_handle, offset, whence);
# endif

	if (ret == -1)
		@throw [OFSeekFailedException exceptionWithStream: self

Modified src/OFFileURLHandler.m from [4a5233a57f] to [ad06f1fab8].

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	of_time_interval_t st_atime, st_mtime, st_ctime;
# ifdef OF_WINDOWS
#  define HAVE_STRUCT_STAT_ST_BIRTHTIME
	of_time_interval_t st_birthtime;
	DWORD fileAttributes;
# endif
} of_stat_t;
#elif defined(OF_HAVE_OFF64_T)
typedef struct stat64 of_stat_t;
#else
typedef struct stat of_stat_t;
#endif

#ifdef OF_WINDOWS
# define S_IFLNK 0x10000







|







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	of_time_interval_t st_atime, st_mtime, st_ctime;
# ifdef OF_WINDOWS
#  define HAVE_STRUCT_STAT_ST_BIRTHTIME
	of_time_interval_t st_birthtime;
	DWORD fileAttributes;
# endif
} of_stat_t;
#elif defined(HAVE_STAT64)
typedef struct stat64 of_stat_t;
#else
typedef struct stat of_stat_t;
#endif

#ifdef OF_WINDOWS
# define S_IFLNK 0x10000
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval;

# ifdef OF_AMIGAOS4
	FreeDosObject(DOS_EXAMINEDATA, ed);
# endif

	return 0;
#elif defined(OF_HAVE_OFF64_T)
	return stat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
#else
	return stat([path cStringWithEncoding: [OFLocale encoding]], buffer);
#endif
}

static int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && \
    !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
# ifdef OF_HAVE_OFF64_T
	return lstat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
# else
	return lstat([path cStringWithEncoding: [OFLocale encoding]], buffer);
# endif
#else
	return of_stat(path, buffer);
#endif







|











|







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval;

# ifdef OF_AMIGAOS4
	FreeDosObject(DOS_EXAMINEDATA, ed);
# endif

	return 0;
#elif defined(HAVE_STAT64)
	return stat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
#else
	return stat([path cStringWithEncoding: [OFLocale encoding]], buffer);
#endif
}

static int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && \
    !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
# ifdef HAVE_LSTAT64
	return lstat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
# else
	return lstat([path cStringWithEncoding: [OFLocale encoding]], buffer);
# endif
#else
	return of_stat(path, buffer);
#endif