ObjFW  Check-in [2f5af58573]

Overview
Comment:Use -std=c11 instead of -std=gnu11

Not using -std=gnu11 means _GNU_SOURCE does not get defined anymore,
therefore this commit also adds the required feature defines for glibc.

Additionally, this adds of_strdup in macros.h, as strdup is an
extension.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2f5af58573de3ba1cb5dcf0f94bf0454515923fcae043646033ce1d47d9755b3
User & Date: js on 2014-02-13 23:26:17
Other Links: manifest | tags
Context
2014-02-15
01:20
configure: Better document --seluid24 check-in: 1ad952e9ed user: js tags: trunk
2014-02-13
23:26
Use -std=c11 instead of -std=gnu11 check-in: 2f5af58573 user: js tags: trunk
16:29
runtime/class.m: Better handling of Nil parameters check-in: 52c0e9f94e user: js tags: trunk
Changes

Modified configure.ac from [1da639e3ca] to [13f29be000].

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
AC_PROG_EGREP

CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions -funwind-tables"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"

AX_CHECK_COMPILER_FLAGS(-std=gnu11, [
	OBJCFLAGS="$OBJCFLAGS -std=gnu11"
], [
	AX_CHECK_COMPILER_FLAGS(-std=gnu99,
		[OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
])

case $OBJC in
	*clang*)
		;;
	*)
		AX_CHECK_COMPILER_FLAGS([-fgnu89-inline -Werror],
			[OBJCFLAGS="$OBJCFLAGS -fgnu89-inline"])
		;;
esac
AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
	AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings")
])
AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32 -Werror,







|
|

|
<


<
<
<
<
<
<
<
<







56
57
58
59
60
61
62
63
64
65
66

67
68








69
70
71
72
73
74
75
AC_PROG_EGREP

CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions -funwind-tables"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"

AX_CHECK_COMPILER_FLAGS(-std=c11, [
	OBJCFLAGS="$OBJCFLAGS -std=c11"
], [
	AX_CHECK_COMPILER_FLAGS(-std=c99, [OBJCFLAGS="$OBJCFLAGS -std=c99"])

])









AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
	AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings")
])
AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32 -Werror,

Modified src/OFDate.m from [8e1ed139e9] to [f7a0f4a2c6].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
24
25
26
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#define _GNU_SOURCE
#include <stdint.h>
#include <limits.h>
#include <time.h>
#include <math.h>
#include <float.h>

#include <sys/time.h>







>
>


<







10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _POSIX_SOURCE

#include "config.h"


#include <stdint.h>
#include <limits.h>
#include <time.h>
#include <math.h>
#include <float.h>

#include <sys/time.h>

Modified src/OFFile.m from [08425887c5] to [3c2eb32352].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#define __NO_EXT_QNX

/* Work around a bug with Clang + glibc */
#ifdef __clang__







>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _POSIX_C_SOURCE 200112L

#include "config.h"

#define __NO_EXT_QNX

/* Work around a bug with Clang + glibc */
#ifdef __clang__

Modified src/OFHTTPServer.m from [3104ed8898] to [48d8bdc4b1].

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
		return NULL;
	}
}

static OF_INLINE OFString*
normalizedKey(OFString *key)
{
	char *cString = strdup([key UTF8String]);
	uint8_t *tmp = (uint8_t*)cString;
	bool firstLetter = true;

	if (cString == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: strlen([key UTF8String])];








|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
		return NULL;
	}
}

static OF_INLINE OFString*
normalizedKey(OFString *key)
{
	char *cString = of_strdup([key UTF8String]);
	uint8_t *tmp = (uint8_t*)cString;
	bool firstLetter = true;

	if (cString == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: strlen([key UTF8String])];

Modified src/OFMapTable.m from [9d63848c2d] to [dffae0d500].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#include <string.h>

#include <assert.h>








>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _BSD_SOURCE

#include "config.h"

#include <string.h>

#include <assert.h>

Modified src/OFObject.m from [ca87b4ce10] to [f4d9610474].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>








>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _BSD_SOURCE

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Modified src/OFProcess.m from [754335c8dd] to [69b09cd9ef].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#include <string.h>

#ifndef _WIN32
# include <unistd.h>







>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _POSIX_SOURCE

#include "config.h"

#include <string.h>

#ifndef _WIN32
# include <unistd.h>

Modified src/OFThread.m from [bbc593cb97] to [621dd2e5a4].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#define OF_THREAD_M

#define _POSIX_TIMERS
#define __NO_EXT_QNX







>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _POSIX_C_SOURCE 199309

#include "config.h"

#define OF_THREAD_M

#define _POSIX_TIMERS
#define __NO_EXT_QNX

Modified src/OFURL.m from [9604342a66] to [50139ad3bd].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	char *UTF8String, *UTF8String2 = NULL;

	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize: [string
							     UTF8StringLength]];

		UTF8String = UTF8String2;

		if (!strncmp(UTF8String, "file://", 7)) {







|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	char *UTF8String, *UTF8String2 = NULL;

	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((UTF8String2 = of_strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize: [string
							     UTF8StringLength]];

		UTF8String = UTF8String2;

		if (!strncmp(UTF8String, "file://", 7)) {
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

		_scheme = [URL->_scheme copy];
		_host = [URL->_host copy];
		_port = URL->_port;
		_user = [URL->_user copy];
		_password = [URL->_password copy];

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize:
			     [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if ((tmp = strchr(UTF8String, '#')) != NULL) {







|







190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

		_scheme = [URL->_scheme copy];
		_host = [URL->_host copy];
		_port = URL->_port;
		_user = [URL->_user copy];
		_password = [URL->_password copy];

		if ((UTF8String2 = of_strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize:
			     [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if ((tmp = strchr(UTF8String, '#')) != NULL) {

Modified src/exceptions/OFAddressTranslationFailedException.m from [978b1ac512] to [2cd958f861].

9
10
11
12
13
14
15


16
17
18
19
20
21
22
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#import "OFAddressTranslationFailedException.h"
#import "OFString.h"

#import "common.h"







>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _BSD_SOURCE

#include "config.h"

#import "OFAddressTranslationFailedException.h"
#import "OFString.h"

#import "common.h"

Modified src/exceptions/OFException.m from [5e0042a4d3] to [daa1364182].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#define _GNU_SOURCE

#include <stdlib.h>

#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif








|

|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _GNU_SOURCE

#include "config.h"

#include <stdlib.h>

#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif

Modified src/exceptions/common.h from [b809e736ac] to [8eded04c5d].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 */

#include <string.h>
#include <errno.h>

#import "macros.h"

#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif

#ifndef _WIN32
# define GET_ERRNO	errno
# ifdef OF_HAVE_SOCKETS
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_H_ERRNO)
#   define GET_AT_ERRNO	h_errno







|
|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 */

#include <string.h>
#include <errno.h>

#import "macros.h"

#ifdef OF_HAVE_SOCKETS
# include "socket_helpers.h"
#endif

#ifndef _WIN32
# define GET_ERRNO	errno
# ifdef OF_HAVE_SOCKETS
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_H_ERRNO)
#   define GET_AT_ERRNO	h_errno

Modified src/macros.h from [f7dad7806c] to [3858acab50].

16
17
18
19
20
21
22

23
24
25
26
27
28
29

#import "OFObject.h"

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>


#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))







>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#import "OFObject.h"

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
407
408
409
410
411
412
413














	of_rectangle_t rectangle = {
		of_point(x, y),
		of_dimension(width, height)
	};

	return rectangle;
}





















>
>
>
>
>
>
>
>
>
>
>
>
>
>
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
	of_rectangle_t rectangle = {
		of_point(x, y),
		of_dimension(width, height)
	};

	return rectangle;
}

static OF_INLINE char*
of_strdup(const char *string)
{
	char *copy;
	size_t length = strlen(string);

	if ((copy = malloc(length + 1)) == NULL)
		return NULL;

	memcpy(copy, string, length + 1);

	return copy;
}

Modified src/of_asprintf.m from [0550f8c820] to [9e4f7d3917].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
24
25
26
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */



#include "config.h"

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>








>
>


<







10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#define _GNU_SOURCE

#include "config.h"


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>

Modified src/runtime/selector.m from [e3b6fb662f] to [915bbfe8d7].

19
20
21
22
23
24
25


26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "runtime.h"
#import "runtime-private.h"



#ifdef OF_SELUID24
# define SEL_MAX 0xFFFFFF
#else
# define SEL_MAX 0xFFFF
#endif

static struct objc_hashtable *selectors = NULL;







>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "runtime.h"
#import "runtime-private.h"

#import "macros.h"

#ifdef OF_SELUID24
# define SEL_MAX 0xFFFFFF
#else
# define SEL_MAX 0xFFFF
#endif

static struct objc_hashtable *selectors = NULL;
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
		objc_global_mutex_unlock();
		return (SEL)rsel;
	}

	if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");

	if ((sel->name = strdup(name)) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");

	sel->types = NULL;

	if ((free_list = realloc(free_list,
	    sizeof(void*) * (free_list_cnt + 2))) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");







|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
		objc_global_mutex_unlock();
		return (SEL)rsel;
	}

	if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");

	if ((sel->name = of_strdup(name)) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");

	sel->types = NULL;

	if ((free_list = realloc(free_list,
	    sizeof(void*) * (free_list_cnt + 2))) == NULL)
		OBJC_ERROR("Not enough memory to allocate selector!");