Skip to content

Commit 2377e5f

Browse files
committed
fixes for compiler warnings
Collection of small fixes to eliminate compiler warnings when building libdispatch and its tests.
1 parent 272e818 commit 2377e5f

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/BlocksRuntime/data.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ We allocate space and export a symbol to be used as the Class for the on-stack a
1414
1515
We keep these in a separate file so that we can include the runtime code in test subprojects but not include the data so that compiled code that sees the data in libSystem doesn't get confused by a second copy. Somehow these don't get unified in a common block.
1616
**********************/
17-
#define BLOCK_EXPORT extern __attribute__((visibility("default")))
17+
#define BLOCK_EXPORT __attribute__((visibility("default")))
1818

1919
BLOCK_EXPORT void * _NSConcreteStackBlock[32] = { 0 };
2020
BLOCK_EXPORT void * _NSConcreteMallocBlock[32] = { 0 };

src/BlocksRuntime/runtime.c

+6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ static __inline bool OSAtomicCompareAndSwapInt(int oldi, int newi, int volatile
5353
Globals
5454
************************/
5555

56+
#if HAVE_OBJC
5657
static void *_Block_copy_class = _NSConcreteMallocBlock;
5758
static void *_Block_copy_finalizing_class = _NSConcreteMallocBlock;
5859
static int _Block_copy_flag = BLOCK_NEEDS_FREE;
60+
#endif
5961
static int _Byref_flag_initial_value = BLOCK_BYREF_NEEDS_FREE | 4; // logical 2
6062

6163
static bool isGC = false;
@@ -156,7 +158,9 @@ static void _Block_assign_default(void *value, void **destptr) {
156158
static void _Block_setHasRefcount_default(const void *ptr, const bool hasRefcount) {
157159
}
158160

161+
#if HAVE_OBJC
159162
static void _Block_do_nothing(const void *aBlock) { }
163+
#endif
160164

161165
static void _Block_retain_object_default(const void *ptr) {
162166
}
@@ -176,6 +180,7 @@ static void _Block_memmove_default(void *dst, void *src, unsigned long size) {
176180
memmove(dst, src, (size_t)size);
177181
}
178182

183+
#if HAVE_OBJC
179184
static void _Block_memmove_gc_broken(void *dest, void *src, unsigned long size) {
180185
void **destp = (void **)dest;
181186
void **srcp = (void **)src;
@@ -186,6 +191,7 @@ static void _Block_memmove_gc_broken(void *dest, void *src, unsigned long size)
186191
size -= sizeof(void *);
187192
}
188193
}
194+
#endif
189195

190196
static void _Block_destructInstance_default(const void *aBlock) {}
191197

src/source.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ _dispatch_source_debug_attr(dispatch_source_t ds, char* buf, size_t bufsiz)
25152515
"mask = 0x%x, pending_data = 0x%llx, registered = %d, "
25162516
"armed = %d, deleted = %d%s, canceled = %d, ",
25172517
target && target->dq_label ? target->dq_label : "", target,
2518-
dr->du_ident, dr->du_fflags, ds->ds_pending_data,
2518+
dr->du_ident, dr->du_fflags, (unsigned long long)ds->ds_pending_data,
25192519
ds->ds_is_installed, (bool)(ds->dq_atomic_flags & DSF_ARMED),
25202520
(bool)(ds->dq_atomic_flags & DSF_DELETED),
25212521
(ds->dq_atomic_flags & DSF_DEFERRED_DELETE) ? " (pending)" : "",

tests/dispatch_data.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ test_concat(void)
7979
static void
8080
test_cleanup(void) // <rdar://problem/9843440>
8181
{
82+
static char buffer4[16];
8283
dispatch_group_enter(g);
8384
dispatch_async(dispatch_get_main_queue(), ^{
8485
void *buffer3 = malloc(1024);
8586
dispatch_data_t data3 = dispatch_data_create(buffer3, 0,
8687
dispatch_get_main_queue(), DISPATCH_DATA_DESTRUCTOR_FREE);
8788
__block bool buffer4_destroyed = false;
88-
dispatch_data_t data4 = dispatch_data_create(NULL, 1024,
89+
dispatch_data_t data4 = dispatch_data_create(buffer4, 16,
8990
dispatch_get_main_queue(), ^{
9091
buffer4_destroyed = true;
9192
});

0 commit comments

Comments
 (0)