Skip to content

Commit ac5f4c4

Browse files
Merge pull request #384 from adierking/unixstubs
Remove generic_unix_stubs
2 parents 653a523 + 02b6964 commit ac5f4c4

File tree

8 files changed

+59
-149
lines changed

8 files changed

+59
-149
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ add_library(dispatch
5454
shims/time.h
5555
shims/tsd.h
5656
shims/yield.h)
57-
if(UNIX)
58-
target_sources(dispatch
59-
PRIVATE
60-
shims/generic_unix_stubs.c
61-
shims/generic_unix_stubs.h)
62-
elseif(WIN32)
57+
if(WIN32)
6358
target_sources(dispatch
6459
PRIVATE
6560
shims/generic_sys_queue.h

src/shims.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
#if defined(_WIN32)
3434
#include "shims/generic_win_stubs.h"
3535
#include "shims/generic_sys_queue.h"
36-
#elif defined(__unix__)
37-
#include "shims/generic_unix_stubs.h"
3836
#endif
3937

4038
#ifdef __ANDROID__
4139
#include "shims/android_stubs.h"
4240
#endif
4341

42+
#if !HAVE_MACH
43+
#include "shims/mach.h"
44+
#endif
45+
4446
#include "shims/hw_config.h"
4547
#include "shims/priority.h"
4648

@@ -79,6 +81,12 @@ size_t strlcpy(char *dst, const char *src, size_t size);
7981

8082
#endif // HAVE_STRLCPY
8183

84+
#ifndef TAILQ_FOREACH_SAFE
85+
#define TAILQ_FOREACH_SAFE(var, head, field, temp) \
86+
for ((var) = TAILQ_FIRST((head)); \
87+
(var) && ((temp) = TAILQ_NEXT((var), field), 1); (var) = (temp))
88+
#endif
89+
8290
#if PTHREAD_WORKQUEUE_SPI_VERSION < 20140716
8391
static inline int
8492
_pthread_workqueue_override_start_direct(mach_port_t thread,

src/shims/generic_sys_queue.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@
6262
(var) != NULL; \
6363
(var) = TAILQ_NEXT(var, field))
6464

65-
#define TAILQ_FOREACH_SAFE(var, list, field, temp) \
66-
for ((var) = TAILQ_FIRST(list); \
67-
((var) != NULL) && (temp = TAILQ_NEXT(var, field), 1); \
68-
(var) = (temp))
69-
7065
#define TAILQ_REMOVE(list, elem, field) do { \
7166
if (TAILQ_NEXT(elem, field) != NULL) { \
7267
TAILQ_NEXT(elem, field)->field.te_prev = (elem)->field.te_prev; \

src/shims/generic_unix_stubs.c

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/shims/generic_unix_stubs.h

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/shims/generic_win_stubs.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,9 @@
1111
#include <process.h>
1212

1313
/*
14-
* Stub out defines for some mach types and related macros
14+
* Stub out defines for missing types
1515
*/
1616

17-
typedef uint32_t mach_port_t;
18-
19-
#define MACH_PORT_NULL (0)
20-
21-
typedef uint32_t mach_msg_bits_t;
22-
typedef void *mach_msg_header_t;
23-
24-
/*
25-
* Stub out defines for other missing types
26-
*/
27-
28-
// SIZE_T_MAX should not be hardcoded like this here.
29-
#ifndef SIZE_T_MAX
30-
#define SIZE_T_MAX (~(size_t)0)
31-
#endif
32-
3317
typedef __typeof__(_Generic((__SIZE_TYPE__)0, \
3418
unsigned long long int : (long long int)0, \
3519
unsigned long int : (long int)0, \

src/shims/mach.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2018 Apple Inc. All rights reserved.
3+
*
4+
* @APPLE_APACHE_LICENSE_HEADER_START@
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @APPLE_APACHE_LICENSE_HEADER_END@
19+
*/
20+
21+
#ifndef __DISPATCH_SHIMS_MACH__
22+
#define __DISPATCH_SHIMS_MACH__
23+
24+
/*
25+
* Stub out defines for some mach types and related macros
26+
*/
27+
28+
typedef uint32_t mach_port_t;
29+
30+
#define MACH_PORT_NULL (0)
31+
#define MACH_PORT_DEAD (-1)
32+
33+
typedef uint32_t mach_error_t;
34+
35+
typedef uint32_t mach_msg_return_t;
36+
37+
typedef uint32_t mach_msg_bits_t;
38+
39+
typedef void *dispatch_mach_msg_t;
40+
41+
typedef uint64_t firehose_activity_id_t;
42+
43+
typedef void *mach_msg_header_t;
44+
45+
#endif

src/transform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ _dispatch_transform_to_base32_with_table(dispatch_data_t data, const unsigned ch
662662
dest_size = howmany(total, 5);
663663
// <rdar://problem/25676583>
664664
// os_mul_overflow(dest_size, 8, &dest_size)
665-
if (dest_size > SIZE_T_MAX / 8) {
665+
if (dest_size > SIZE_MAX / 8) {
666666
return NULL;
667667
}
668668
dest_size *= 8;
@@ -897,7 +897,7 @@ _dispatch_transform_to_base64(dispatch_data_t data)
897897
dest_size = howmany(total, 3);
898898
// <rdar://problem/25676583>
899899
// os_mul_overflow(dest_size, 4, &dest_size)
900-
if (dest_size > SIZE_T_MAX / 4) {
900+
if (dest_size > SIZE_MAX / 4) {
901901
return NULL;
902902
}
903903
dest_size *= 4;

0 commit comments

Comments
 (0)