ObjFW  Check-in [832188d759]

Overview
Comment:Rename OFMacros.h to macros.h, as it's not a class.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 832188d759dcf9751da7a02bbe1fc142cd0030b5623c39403977748c607ef78d
User & Date: js on 2010-02-02 18:58:24
Other Links: manifest | tags
Context
2010-02-05
14:00
Small optimization for -[componentsJoinedByString:]. check-in: 0ccbebce04 user: js tags: trunk
2010-02-02
18:58
Rename OFMacros.h to macros.h, as it's not a class. check-in: 832188d759 user: js tags: trunk
15:41
Fix VERSION in objfw-config.in. check-in: 999bfb135f user: js tags: trunk
Changes

Modified src/Makefile from [b004a3e1eb] to [3a32fe0336].

27
28
29
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
       ${OFTHREAD_M}		\
       OFURLEncoding.m		\
       OFXMLElement.m		\
       OFXMLParser.m		\
       unicode.m

INCLUDES := ${SRCS:.m=.h}	\
	    OFMacros.h		\
	    ObjFW.h		\
	    asprintf.h		\
	    ${ATOMIC_H}		\

	    objfw-defs.h	\
	    ${THREADING_H}

SRCS += ${ASPRINTF_M} 		\
	iso_8859_15.m		\
	windows_1252.m		\
	${OBJC_PROPERTIES_M}	\







<



>







27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
44
       ${OFTHREAD_M}		\
       OFURLEncoding.m		\
       OFXMLElement.m		\
       OFXMLParser.m		\
       unicode.m

INCLUDES := ${SRCS:.m=.h}	\

	    ObjFW.h		\
	    asprintf.h		\
	    ${ATOMIC_H}		\
	    macros.h		\
	    objfw-defs.h	\
	    ${THREADING_H}

SRCS += ${ASPRINTF_M} 		\
	iso_8859_15.m		\
	windows_1252.m		\
	${OBJC_PROPERTIES_M}	\

Modified src/OFArray.m from [56c9de1a04] to [8b2d803278].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"

@implementation OFArray
+ array
{
	return [[[self alloc] init] autorelease];
}








|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

@implementation OFArray
+ array
{
	return [[[self alloc] init] autorelease];
}

Modified src/OFDataArray.m from [b89c31d500] to [9d66eb1125].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>

#import "OFDataArray.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#ifdef _WIN32
#include <windows.h>
#endif

static int lastpagebyte = 0;








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>

#import "OFDataArray.h"
#import "OFExceptions.h"
#import "macros.h"

#ifdef _WIN32
#include <windows.h>
#endif

static int lastpagebyte = 0;

Modified src/OFDictionary.m from [c81ffb2e26] to [c2d0cafc7c].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>

#import "OFDictionary.h"
#import "OFEnumerator.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#define BUCKET_SIZE sizeof(struct of_dictionary_bucket)

@implementation OFDictionary
+ dictionary;
{
	return [[[self alloc] init] autorelease];







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>

#import "OFDictionary.h"
#import "OFEnumerator.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

#define BUCKET_SIZE sizeof(struct of_dictionary_bucket)

@implementation OFDictionary
+ dictionary;
{
	return [[[self alloc] init] autorelease];

Modified src/OFHashes.m from [78b7e000bc] to [ec07de4144].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "config.h"

#include <string.h>

#import "OFHashes.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFHashing_reference;

/*
 * MD5
 */








|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "config.h"

#include <string.h>

#import "OFHashes.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

int _OFHashing_reference;

/*
 * MD5
 */

Modified src/OFList.m from [157ed5cd6f] to [d50e255a0f].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include "config.h"

#include "assert.h"

#import "OFList.h"
#import "OFExceptions.h"
#import "OFMacros.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
}








|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include "config.h"

#include "assert.h"

#import "OFList.h"
#import "OFExceptions.h"
#import "macros.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
}

Deleted src/OFMacros.h version [423a04e77c].

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
51
52
53
54
55
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "objfw-defs.h"

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

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
# define OF_LIKELY(cond) __builtin_expect(!!(cond), 1)
# define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
#else
# define OF_INLINE inline
# define OF_LIKELY(cond) cond
# define OF_UNLIKELY(cond) cond
#endif

/* Required to build universal binaries on OS X */
#if __BIG_ENDIAN__ || __LITTLE_ENDIAN__
# if __BIG_ENDIAN__ && __LITTLE_ENDIAN__
#  error __BIG_ENDIAN__ and __LITTLE_ENDIAN__ defined!
# endif
# undef OF_BIG_ENDIAN
# if __BIG_ENDIAN__
#  define OF_BIG_ENDIAN
# endif
#endif

#ifdef __GNUC__
# if defined(__amd64__) || defined(__x86_64__)
#  define OF_AMD64_ASM
# elif defined(__i386__)
#  define OF_X86_ASM
# elif defined(__ppc__) || defined(__PPC__)
#  define OF_PPC_ASM
# elif defined(__arm__) || defined(__ARM__)
#  define OF_ARM_ASM
# endif
#endif

#define OF_BSWAP16_CONST(i)					\
	(((uint16_t)i & UINT16_C(0xFF00)) >> 8 |		\
	 ((uint16_t)i & UINT16_C(0x00FF)) << 8)
#define OF_BSWAP32_CONST(i)					\
	(((uint32_t)i & UINT32_C(0xFF000000)) >> 24 |		\
	 ((uint32_t)i & UINT32_C(0x00FF0000)) >>  8 |		\
	 ((uint32_t)i & UINT32_C(0x0000FF00)) <<  8 |		\
	 ((uint32_t)i & UINT32_C(0x000000FF)) << 24)
#define OF_BSWAP64_CONST(i)					\
	(((uint64_t)i & UINT64_C(0xFF00000000000000)) >> 56 |	\
	 ((uint64_t)i & UINT64_C(0x00FF000000000000)) >> 40 |	\
	 ((uint64_t)i & UINT64_C(0x0000FF0000000000)) >> 24 |	\
	 ((uint64_t)i & UINT64_C(0x000000FF00000000)) >>  8 |	\
	 ((uint64_t)i & UINT64_C(0x00000000FF000000)) <<  8 |	\
	 ((uint64_t)i & UINT64_C(0x0000000000FF0000)) << 24 |	\
	 ((uint64_t)i & UINT64_C(0x000000000000FF00)) << 40 |	\
	 ((uint64_t)i & UINT64_C(0x00000000000000FF)) << 56)

static OF_INLINE uint16_t
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("xchgb	%h0, %b0" : "=Q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lhbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev16	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
#endif
	return i;
}

static OF_INLINE uint32_t
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lwbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT32_C(0xFF000000)) >> 24 |
	    (i & UINT32_C(0x00FF0000)) >>  8 |
	    (i & UINT32_C(0x0000FF00)) <<  8 |
	    (i & UINT32_C(0x000000FF)) << 24;
#endif
	return i;
}

static OF_INLINE uint64_t
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=r"(i) : "0"(i));
#elif defined(OF_X86_ASM)
	asm("bswap	%%eax\n\t"
	    "bswap	%%edx\n\t"
	    "xchgl	%%eax, %%edx" : "=A"(i): "0"(i));
#else
	i = (uint64_t)OF_BSWAP32_NONCONST(i & 0xFFFFFFFF) << 32 |
	    OF_BSWAP32_NONCONST(i >> 32);
#endif
	return i;
}

#ifdef __GNUC__
# define OF_BSWAP16(i) \
	(__builtin_constant_p(i) ? OF_BSWAP16_CONST(i) : OF_BSWAP16_NONCONST(i))
# define OF_BSWAP32(i) \
	(__builtin_constant_p(i) ? OF_BSWAP32_CONST(i) : OF_BSWAP32_NONCONST(i))
# define OF_BSWAP64(i) \
	(__builtin_constant_p(i) ? OF_BSWAP64_CONST(i) : OF_BSWAP64_NONCONST(i))
#else
# define OF_BSWAP16(i) OF_BSWAP16_CONST(i)
# define OF_BSWAP32(i) OF_BSWAP32_CONST(i)
# define OF_BSWAP64(i) OF_BSWAP64_CONST(i)
#endif

static OF_INLINE void
OF_BSWAP32_V(uint32_t *buf, size_t len)
{
	while (len--) {
		*buf = OF_BSWAP32(*buf);
		buf++;
	}
}

#ifdef OF_BIG_ENDIAN
# define OF_BSWAP16_IF_BE(i) OF_BSWAP16(i)
# define OF_BSWAP32_IF_BE(i) OF_BSWAP32(i)
# define OF_BSWAP64_IF_BE(i) OF_BSWAP64(i)
# define OF_BSWAP16_IF_LE(i) i
# define OF_BSWAP32_IF_LE(i) i
# define OF_BSWAP64_IF_LE(i) i
# define OF_BSWAP32_V_IF_BE(buf, len) OF_BSWAP32_V(buf, len)
#else
# define OF_BSWAP16_IF_BE(i) i
# define OF_BSWAP32_IF_BE(i) i
# define OF_BSWAP64_IF_BE(i) i
# define OF_BSWAP16_IF_LE(i) OF_BSWAP16(i)
# define OF_BSWAP32_IF_LE(i) OF_BSWAP32(i)
# define OF_BSWAP64_IF_LE(i) OF_BSWAP64(i)
# define OF_BSWAP32_V_IF_BE(buf, len)
#endif

#define OF_ROL(val, bits) \
	(((val) << (bits)) | ((val) >> (32 - (bits))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\
	{				\
		hash += byte;		\
		hash += (hash << 10);	\
		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































Modified src/OFMutableDictionary.m from [a965448013] to [9dc55644e5].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include "config.h"

#include <string.h>

#import "OFMutableDictionary.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#define BUCKET_SIZE sizeof(struct of_dictionary_bucket)

static OF_INLINE void
resize(id self, Class isa, size_t count, struct of_dictionary_bucket **data,
    size_t *size)
{







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include "config.h"

#include <string.h>

#import "OFMutableDictionary.h"
#import "OFExceptions.h"
#import "macros.h"

#define BUCKET_SIZE sizeof(struct of_dictionary_bucket)

static OF_INLINE void
resize(id self, Class isa, size_t count, struct of_dictionary_bucket **data,
    size_t *size)
{

Modified src/OFMutableString.m from [2a95dc6ba0] to [ca1764da14].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <sys/mman.h>
#else
#define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#import "asprintf.h"
#import "unicode.h"

static void
apply_table(id self, Class isa, char **string, unsigned int *length,
    BOOL is_utf8, const of_unichar_t* const table[], const size_t table_size)







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <sys/mman.h>
#else
#define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"
#import "unicode.h"

static void
apply_table(id self, Class isa, char **string, unsigned int *length,
    BOOL is_utf8, const of_unichar_t* const table[], const size_t table_size)

Modified src/OFObject.m from [357eadb4d2] to [747590c79e].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <string.h>
#include <limits.h>
#include <assert.h>

#import "OFObject.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#import <objc/objc-api.h>
#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef OF_GNU_RUNTIME
# import <objc/sarray.h>







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <string.h>
#include <limits.h>
#include <assert.h>

#import "OFObject.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

#import <objc/objc-api.h>
#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef OF_GNU_RUNTIME
# import <objc/sarray.h>

Modified src/OFStream.m from [c12185893b] to [b0b53ca7b3].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>
#include <unistd.h>
#include <assert.h>

#import "OFStream.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#ifdef _WIN32
#include <windows.h>
#endif

static int pagesize = 0;








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>
#include <unistd.h>
#include <assert.h>

#import "OFStream.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#ifdef _WIN32
#include <windows.h>
#endif

static int pagesize = 0;

Modified src/OFString.m from [1aae4ffc35] to [a8326e5274].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#import "asprintf.h"
#import "unicode.h"

extern const uint16_t of_iso_8859_15[256];
extern const uint16_t of_windows_1252[256];








|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"
#import "unicode.h"

extern const uint16_t of_iso_8859_15[256];
extern const uint16_t of_windows_1252[256];

Modified src/OFTCPSocket.m from [0a606f2f49] to [b3b2edf858].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#if !defined(HAVE_THREADSAFE_GETADDRINFO) && !defined(_WIN32)
# include <netinet/in.h>
#endif

#import "OFTCPSocket.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#ifndef INVALID_SOCKET
# define INVALID_SOCKET -1
#endif

#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
# import "OFThread.h"







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#if !defined(HAVE_THREADSAFE_GETADDRINFO) && !defined(_WIN32)
# include <netinet/in.h>
#endif

#import "OFTCPSocket.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#ifndef INVALID_SOCKET
# define INVALID_SOCKET -1
#endif

#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
# import "OFThread.h"

Modified src/OFXMLParser.m from [08dd8b2077] to [b0986c8ab9].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>

#import "OFXMLParser.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFXMLParser_reference;

static OF_INLINE OFString*
transform_string(OFMutableString *cache,
    OFObject <OFXMLUnescapingDelegate> *handler)
{







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>

#import "OFXMLParser.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

int _OFXMLParser_reference;

static OF_INLINE OFString*
transform_string(OFMutableString *cache,
    OFObject <OFXMLUnescapingDelegate> *handler)
{

Modified src/ObjFW.h from [298408d0be] to [1e4ff89001].

1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer "js@webkeks.org"
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import "OFObject.h"
#import "OFExceptions.h"

#import "OFAutoreleasePool.h"
#import "OFString.h"

#import "OFDataArray.h"











>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer "js@webkeks.org"
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "objfw-defs.h"

#import "OFObject.h"
#import "OFExceptions.h"

#import "OFAutoreleasePool.h"
#import "OFString.h"

#import "OFDataArray.h"
39
40
41
42
43
44
45
46
47


#import "OFPlugin.h"
#endif

#ifdef OF_THREADS
#import "OFThread.h"
#endif

#import "OFMacros.h"
#import "asprintf.h"









|
|
>
>
41
42
43
44
45
46
47
48
49
50
51
#import "OFPlugin.h"
#endif

#ifdef OF_THREADS
#import "OFThread.h"
#endif

#import "asprintf.h"
#import "atomic.h"
#import "macros.h"
#import "threading.h"

Modified src/atomic.h from [465cd0b0aa] to [9244f42746].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFMacros.h"

#if defined(OF_THREADS) && !defined(OF_HAVE_GCC_ATOMIC_OPS) && \
    !defined(OF_HAVE_LIBKERN_OSATOMIC_H)
# error No atomic operations available!
#endif

#ifdef OF_HAVE_LIBKERN_OSATOMIC_H











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "macros.h"

#if defined(OF_THREADS) && !defined(OF_HAVE_GCC_ATOMIC_OPS) && \
    !defined(OF_HAVE_LIBKERN_OSATOMIC_H)
# error No atomic operations available!
#endif

#ifdef OF_HAVE_LIBKERN_OSATOMIC_H

Added src/macros.h version [423a04e77c].



























































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
51
52
53
54
55
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "objfw-defs.h"

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

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
# define OF_LIKELY(cond) __builtin_expect(!!(cond), 1)
# define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
#else
# define OF_INLINE inline
# define OF_LIKELY(cond) cond
# define OF_UNLIKELY(cond) cond
#endif

/* Required to build universal binaries on OS X */
#if __BIG_ENDIAN__ || __LITTLE_ENDIAN__
# if __BIG_ENDIAN__ && __LITTLE_ENDIAN__
#  error __BIG_ENDIAN__ and __LITTLE_ENDIAN__ defined!
# endif
# undef OF_BIG_ENDIAN
# if __BIG_ENDIAN__
#  define OF_BIG_ENDIAN
# endif
#endif

#ifdef __GNUC__
# if defined(__amd64__) || defined(__x86_64__)
#  define OF_AMD64_ASM
# elif defined(__i386__)
#  define OF_X86_ASM
# elif defined(__ppc__) || defined(__PPC__)
#  define OF_PPC_ASM
# elif defined(__arm__) || defined(__ARM__)
#  define OF_ARM_ASM
# endif
#endif

#define OF_BSWAP16_CONST(i)					\
	(((uint16_t)i & UINT16_C(0xFF00)) >> 8 |		\
	 ((uint16_t)i & UINT16_C(0x00FF)) << 8)
#define OF_BSWAP32_CONST(i)					\
	(((uint32_t)i & UINT32_C(0xFF000000)) >> 24 |		\
	 ((uint32_t)i & UINT32_C(0x00FF0000)) >>  8 |		\
	 ((uint32_t)i & UINT32_C(0x0000FF00)) <<  8 |		\
	 ((uint32_t)i & UINT32_C(0x000000FF)) << 24)
#define OF_BSWAP64_CONST(i)					\
	(((uint64_t)i & UINT64_C(0xFF00000000000000)) >> 56 |	\
	 ((uint64_t)i & UINT64_C(0x00FF000000000000)) >> 40 |	\
	 ((uint64_t)i & UINT64_C(0x0000FF0000000000)) >> 24 |	\
	 ((uint64_t)i & UINT64_C(0x000000FF00000000)) >>  8 |	\
	 ((uint64_t)i & UINT64_C(0x00000000FF000000)) <<  8 |	\
	 ((uint64_t)i & UINT64_C(0x0000000000FF0000)) << 24 |	\
	 ((uint64_t)i & UINT64_C(0x000000000000FF00)) << 40 |	\
	 ((uint64_t)i & UINT64_C(0x00000000000000FF)) << 56)

static OF_INLINE uint16_t
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("xchgb	%h0, %b0" : "=Q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lhbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev16	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
#endif
	return i;
}

static OF_INLINE uint32_t
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lwbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT32_C(0xFF000000)) >> 24 |
	    (i & UINT32_C(0x00FF0000)) >>  8 |
	    (i & UINT32_C(0x0000FF00)) <<  8 |
	    (i & UINT32_C(0x000000FF)) << 24;
#endif
	return i;
}

static OF_INLINE uint64_t
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=r"(i) : "0"(i));
#elif defined(OF_X86_ASM)
	asm("bswap	%%eax\n\t"
	    "bswap	%%edx\n\t"
	    "xchgl	%%eax, %%edx" : "=A"(i): "0"(i));
#else
	i = (uint64_t)OF_BSWAP32_NONCONST(i & 0xFFFFFFFF) << 32 |
	    OF_BSWAP32_NONCONST(i >> 32);
#endif
	return i;
}

#ifdef __GNUC__
# define OF_BSWAP16(i) \
	(__builtin_constant_p(i) ? OF_BSWAP16_CONST(i) : OF_BSWAP16_NONCONST(i))
# define OF_BSWAP32(i) \
	(__builtin_constant_p(i) ? OF_BSWAP32_CONST(i) : OF_BSWAP32_NONCONST(i))
# define OF_BSWAP64(i) \
	(__builtin_constant_p(i) ? OF_BSWAP64_CONST(i) : OF_BSWAP64_NONCONST(i))
#else
# define OF_BSWAP16(i) OF_BSWAP16_CONST(i)
# define OF_BSWAP32(i) OF_BSWAP32_CONST(i)
# define OF_BSWAP64(i) OF_BSWAP64_CONST(i)
#endif

static OF_INLINE void
OF_BSWAP32_V(uint32_t *buf, size_t len)
{
	while (len--) {
		*buf = OF_BSWAP32(*buf);
		buf++;
	}
}

#ifdef OF_BIG_ENDIAN
# define OF_BSWAP16_IF_BE(i) OF_BSWAP16(i)
# define OF_BSWAP32_IF_BE(i) OF_BSWAP32(i)
# define OF_BSWAP64_IF_BE(i) OF_BSWAP64(i)
# define OF_BSWAP16_IF_LE(i) i
# define OF_BSWAP32_IF_LE(i) i
# define OF_BSWAP64_IF_LE(i) i
# define OF_BSWAP32_V_IF_BE(buf, len) OF_BSWAP32_V(buf, len)
#else
# define OF_BSWAP16_IF_BE(i) i
# define OF_BSWAP32_IF_BE(i) i
# define OF_BSWAP64_IF_BE(i) i
# define OF_BSWAP16_IF_LE(i) OF_BSWAP16(i)
# define OF_BSWAP32_IF_LE(i) OF_BSWAP32(i)
# define OF_BSWAP64_IF_LE(i) OF_BSWAP64(i)
# define OF_BSWAP32_V_IF_BE(buf, len)
#endif

#define OF_ROL(val, bits) \
	(((val) << (bits)) | ((val) >> (32 - (bits))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\
	{				\
		hash += byte;		\
		hash += (hash << 10);	\
		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}

Modified src/threading.h from [bf0ea6d5c4] to [f03917fe6f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFMacros.h"

#if !defined(OF_THREADS) || (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32))
# error No threads available!
#endif

#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "atomic.h"

#if !defined(OF_THREADS) || (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32))
# error No threads available!
#endif

#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>

Modified tests/OFTCPSocket.m from [6b65fc55ca] to [793aed5e47].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string.h>
#include <time.h>

#import "OFTCPSocket.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#import "main.h"

static OFString *module = @"OFTCPSocket";

void
tcpsocket_tests()







|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string.h>
#include <time.h>

#import "OFTCPSocket.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#import "main.h"

static OFString *module = @"OFTCPSocket";

void
tcpsocket_tests()