Skip to content

Remove generic_unix_stubs #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ add_library(dispatch
shims/time.h
shims/tsd.h
shims/yield.h)
if(UNIX)
target_sources(dispatch
PRIVATE
shims/generic_unix_stubs.c
shims/generic_unix_stubs.h)
elseif(WIN32)
if(WIN32)
target_sources(dispatch
PRIVATE
shims/generic_sys_queue.h
Expand Down
12 changes: 10 additions & 2 deletions src/shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
#if defined(_WIN32)
#include "shims/generic_win_stubs.h"
#include "shims/generic_sys_queue.h"
#elif defined(__unix__)
#include "shims/generic_unix_stubs.h"
#endif

#ifdef __ANDROID__
#include "shims/android_stubs.h"
#endif

#if !HAVE_MACH
#include "shims/mach.h"
#endif

#include "shims/hw_config.h"
#include "shims/priority.h"

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

#endif // HAVE_STRLCPY

#ifndef TAILQ_FOREACH_SAFE
#define TAILQ_FOREACH_SAFE(var, head, field, temp) \
for ((var) = TAILQ_FIRST((head)); \
(var) && ((temp) = TAILQ_NEXT((var), field), 1); (var) = (temp))
#endif

#if PTHREAD_WORKQUEUE_SPI_VERSION < 20140716
static inline int
_pthread_workqueue_override_start_direct(mach_port_t thread,
Expand Down
5 changes: 0 additions & 5 deletions src/shims/generic_sys_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@
(var) != NULL; \
(var) = TAILQ_NEXT(var, field))

#define TAILQ_FOREACH_SAFE(var, list, field, temp) \
for ((var) = TAILQ_FIRST(list); \
((var) != NULL) && (temp = TAILQ_NEXT(var, field), 1); \
(var) = (temp))

#define TAILQ_REMOVE(list, elem, field) do { \
if (TAILQ_NEXT(elem, field) != NULL) { \
TAILQ_NEXT(elem, field)->field.te_prev = (elem)->field.te_prev; \
Expand Down
57 changes: 0 additions & 57 deletions src/shims/generic_unix_stubs.c

This file was deleted.

60 changes: 0 additions & 60 deletions src/shims/generic_unix_stubs.h

This file was deleted.

18 changes: 1 addition & 17 deletions src/shims/generic_win_stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,9 @@
#include <process.h>

/*
* Stub out defines for some mach types and related macros
* Stub out defines for missing types
*/

typedef uint32_t mach_port_t;

#define MACH_PORT_NULL (0)

typedef uint32_t mach_msg_bits_t;
typedef void *mach_msg_header_t;

/*
* Stub out defines for other missing types
*/

// SIZE_T_MAX should not be hardcoded like this here.
#ifndef SIZE_T_MAX
#define SIZE_T_MAX (~(size_t)0)
#endif

typedef __typeof__(_Generic((__SIZE_TYPE__)0, \
unsigned long long int : (long long int)0, \
unsigned long int : (long int)0, \
Expand Down
45 changes: 45 additions & 0 deletions src/shims/mach.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/

#ifndef __DISPATCH_SHIMS_MACH__
#define __DISPATCH_SHIMS_MACH__

/*
* Stub out defines for some mach types and related macros
*/

typedef uint32_t mach_port_t;

#define MACH_PORT_NULL (0)
#define MACH_PORT_DEAD (-1)

typedef uint32_t mach_error_t;

typedef uint32_t mach_msg_return_t;

typedef uint32_t mach_msg_bits_t;

typedef void *dispatch_mach_msg_t;

typedef uint64_t firehose_activity_id_t;

typedef void *mach_msg_header_t;

#endif
4 changes: 2 additions & 2 deletions src/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ _dispatch_transform_to_base32_with_table(dispatch_data_t data, const unsigned ch
dest_size = howmany(total, 5);
// <rdar://problem/25676583>
// os_mul_overflow(dest_size, 8, &dest_size)
if (dest_size > SIZE_T_MAX / 8) {
if (dest_size > SIZE_MAX / 8) {
return NULL;
}
dest_size *= 8;
Expand Down Expand Up @@ -897,7 +897,7 @@ _dispatch_transform_to_base64(dispatch_data_t data)
dest_size = howmany(total, 3);
// <rdar://problem/25676583>
// os_mul_overflow(dest_size, 4, &dest_size)
if (dest_size > SIZE_T_MAX / 4) {
if (dest_size > SIZE_MAX / 4) {
return NULL;
}
dest_size *= 4;
Expand Down