-
Notifications
You must be signed in to change notification settings - Fork 470
Linux port hdd cp1 #3
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
Changes from all commits
f22bc4b
f013a99
fdeae8a
4f9b58c
da3b73d
d7fe4b0
2ab2c26
35984ca
efa2a28
9a39fef
9f4f103
8d8bb46
e0f0522
f38ebb9
a6ede63
16d8a2c
650f82a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
libtool.m4 | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.m4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
osdir=$(includedir)/os | ||
|
||
os_HEADERS= \ | ||
object.h | ||
object.h \ | ||
base.h \ | ||
linux_base.h | ||
|
||
noinst_HEADERS= \ | ||
object_private.h |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Stub out Apple internal header file to redirect to linux_base.h. | ||
// Maybe not the best fix in the long run, but avoids having to #ifdef | ||
// the include of <os/base.h> in all of the other files.... | ||
|
||
#ifndef __OS_BASE__ | ||
#define __OS_BASE__ | ||
|
||
#include <os/linux_base.h> | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* @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 __OS_LINUX_BASE__ | ||
#define __OS_LINUX_BASE__ | ||
|
||
|
||
// marker for hacks we have made to make progress | ||
#define __LINUX_PORT_HDD__ 1 | ||
|
||
/* | ||
* 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 | ||
|
||
#define EVFILT_MACHPORT -8 | ||
|
||
typedef uint32_t mach_error_t; | ||
|
||
typedef uint32_t mach_vm_size_t; | ||
|
||
typedef uint32_t mach_msg_return_t; | ||
|
||
typedef uintptr_t mach_vm_address_t; | ||
|
||
typedef uint32_t dispatch_mach_msg_t; | ||
|
||
typedef uint32_t dispatch_mach_t; | ||
|
||
typedef uint32_t dispatch_mach_reason_t; | ||
|
||
typedef uint32_t voucher_activity_mode_t; | ||
|
||
typedef uint32_t voucher_activity_trace_id_t; | ||
|
||
typedef uint32_t voucher_activity_id_t; | ||
|
||
typedef uint32_t _voucher_activity_buffer_hook_t;; | ||
|
||
typedef uint32_t voucher_activity_flag_t; | ||
|
||
typedef struct | ||
{ | ||
} mach_msg_header_t; | ||
|
||
|
||
typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t, | ||
dispatch_mach_msg_t, mach_error_t); | ||
|
||
typedef void (*dispatch_mach_msg_destructor_t)(void*); | ||
|
||
/* | ||
* Stub out defines for other missing types | ||
*/ | ||
|
||
struct kevent64_s | ||
{ | ||
uint64_t ident; | ||
int16_t filter; | ||
uint16_t flags; | ||
uint32_t fflags; | ||
int64_t data; | ||
uint64_t udata; | ||
uint64_t ext[2]; | ||
}; | ||
|
||
typedef uint32_t voucher_activity_mode_t; | ||
|
||
struct voucher_offsets_s { | ||
uint32_t vo_version; | ||
}; | ||
|
||
|
||
// bogus... | ||
#define PAGE_SIZE 4096 | ||
#define SIZE_T_MAX 0x7fffffff | ||
|
||
#define NOTE_VM_PRESSURE 0 | ||
#define NOTE_ABSOLUTE 0 | ||
#define NOTE_NSECONDS 0 | ||
#define NOTE_LEEWAY 0 | ||
#define NOTE_CRITICAL 0 | ||
#define NOTE_BACKGROUND 0 | ||
|
||
/* | ||
* Stub out misc linking and compilation attributes | ||
*/ | ||
|
||
#ifdef OS_EXPORT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be better to put the |
||
#undef OS_EXPORT | ||
#endif | ||
#define OS_EXPORT | ||
|
||
#ifdef DISPATCH_EXPORT | ||
#undef DISPATCH_EXPORT | ||
#endif | ||
#define DISPATCH_EXPORT | ||
|
||
#ifdef DISPATCH_NONNULL_ALL | ||
#undef DISPATCH_NONNULL_ALL | ||
#endif | ||
#define DISPATCH_NONNULL_ALL | ||
|
||
#ifdef OS_WARN_RESULT_NEEDS_RELEASE | ||
#undef OS_WARN_RESULT_NEEDS_RELEASE | ||
#endif | ||
|
||
#ifdef OS_WARN_RESULT | ||
#undef OS_WARN_RESULT | ||
#endif | ||
#define OS_WARN_RESULT | ||
|
||
#ifdef OS_NOTHROW | ||
#undef OS_NOTHROW | ||
#endif | ||
#define OS_NOTHROW | ||
|
||
|
||
// NOTE (Dave), these and similar macros come from Availabity.h on OS X | ||
#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) // | ||
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(a,b,c,d,msg) // | ||
|
||
|
||
// Print a warning when an unported code path executes. | ||
#define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); } while (0) | ||
|
||
|
||
#endif /* __OS_LINUX_BASE__ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,7 +400,9 @@ dispatch_queue_create_with_accounting_override_voucher(const char *label, | |
* voucher ports directly. | ||
*/ | ||
|
||
#ifdef HAVE_MACH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we cannot have these types of checks in API headers, they will not pass on OSX (nobody defines HAVE_MACH). I would use either |
||
#include <mach/mach.h> | ||
#endif | ||
|
||
/*! | ||
* @function voucher_create_with_mach_msg | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider.h | ||
.libs | ||
*.lo | ||
*.la | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ | |
|
||
|
||
#include <os/object.h> | ||
#include "stubs_internal.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems like the wrong spot for this inclusion, plus we have the shims/ directory for this type of thing already, please use shims.h and add new shims/stubs in there |
||
#include <dispatch/time.h> | ||
#include <dispatch/object.h> | ||
#include <dispatch/queue.h> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -387,9 +387,14 @@ dispatch_io_create_with_path(dispatch_io_type_t type, const char *path, | |
int err = 0; | ||
struct stat st; | ||
_dispatch_io_syscall_switch_noerr(err, | ||
(path_data->oflag & O_NOFOLLOW) == O_NOFOLLOW || | ||
(path_data->oflag & O_SYMLINK) == O_SYMLINK ? | ||
(path_data->oflag & O_NOFOLLOW) == O_NOFOLLOW | ||
#ifdef __LINUX_PORT_HDD__ | ||
? | ||
lstat(path_data->path, &st) : stat(path_data->path, &st), | ||
#else | ||
|| (path_data->oflag & O_SYMLINK) == O_SYMLINK ? | ||
lstat(path_data->path, &st) : stat(path_data->path, &st), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line doesn't seem like it needs to be duplicated ? |
||
#endif | ||
case 0: | ||
err = _dispatch_io_validate_type(channel, st.st_mode); | ||
break; | ||
|
@@ -1777,17 +1782,37 @@ _dispatch_stream_cleanup_operations(dispatch_stream_t stream, | |
dispatch_operation_t op, tmp; | ||
typeof(*stream->operations) *operations; | ||
operations = &stream->operations[DISPATCH_IO_RANDOM]; | ||
#ifdef __LINUX_PORT_HDD__ | ||
LINUX_PORT_ERROR(); | ||
// NOT CORRECT (doesn't support removal during iteration) | ||
TAILQ_FOREACH(op, operations, operation_list) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should add a copy of the bsd sys/queue.h with the safe macros to shims/? (BSD license should be compatible) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or at least a header that adds the missing macros, I really don't like the duplication of all of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. This was intended as a really short term stop-gap to get things to build. Not something that should be merged back. We'll at least pull in the missing safe macros to shims. |
||
if (!channel || op->channel == channel) { | ||
_dispatch_stream_complete_operation(stream, op); | ||
} | ||
} | ||
#else | ||
TAILQ_FOREACH_SAFE(op, operations, operation_list, tmp) { | ||
if (!channel || op->channel == channel) { | ||
_dispatch_stream_complete_operation(stream, op); | ||
} | ||
} | ||
#endif | ||
operations = &stream->operations[DISPATCH_IO_STREAM]; | ||
#ifdef __LINUX_PORT_HDD__ | ||
LINUX_PORT_ERROR(); | ||
// NOT CORRECT (doesn't support removal during iteration) | ||
TAILQ_FOREACH(op, operations, operation_list) { | ||
if (!channel || op->channel == channel) { | ||
_dispatch_stream_complete_operation(stream, op); | ||
} | ||
} | ||
#else | ||
TAILQ_FOREACH_SAFE(op, operations, operation_list, tmp) { | ||
if (!channel || op->channel == channel) { | ||
_dispatch_stream_complete_operation(stream, op); | ||
} | ||
} | ||
#endif | ||
if (stream->source_running && !_dispatch_stream_operation_avail(stream)) { | ||
dispatch_suspend(stream->source); | ||
stream->source_running = false; | ||
|
@@ -1799,11 +1824,21 @@ _dispatch_disk_cleanup_operations(dispatch_disk_t disk, dispatch_io_t channel) | |
{ | ||
// On pick queue | ||
dispatch_operation_t op, tmp; | ||
#ifdef __LINUX_PORT_HDD__ | ||
LINUX_PORT_ERROR(); | ||
// NOT CORRECT (doesn't support removal during iteration) | ||
TAILQ_FOREACH(op, &disk->operations, operation_list) { | ||
if (!channel || op->channel == channel) { | ||
_dispatch_disk_complete_operation(disk, op); | ||
} | ||
} | ||
#else | ||
TAILQ_FOREACH_SAFE(op, &disk->operations, operation_list, tmp) { | ||
if (!channel || op->channel == channel) { | ||
_dispatch_disk_complete_operation(disk, op); | ||
} | ||
} | ||
#endif | ||
} | ||
|
||
#pragma mark - | ||
|
@@ -2064,6 +2099,9 @@ _dispatch_disk_perform(void *ctxt) | |
static void | ||
_dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size) | ||
{ | ||
#ifdef __LINUX_PORT_HDD__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be a configure check for the |
||
LINUX_PORT_ERROR(); | ||
#else | ||
int err; | ||
struct radvisory advise; | ||
// No point in issuing a read advise for the next chunk if we are already | ||
|
@@ -2090,6 +2128,7 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size) | |
// TODO: set disk status on error | ||
default: (void)dispatch_assume_zero(err); break; | ||
); | ||
#endif | ||
} | ||
|
||
static int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is problematic, OSX and iOS already have a public header with this name from a different project and this will conflict
Either we have to conditionalize the install of this header based on platform (and fully replicate its contents from OSX), or we have to conditionalize its inclusion.
an
AC_CHECK_HEADERS([os/base.h])
test in configure.ac would be the standard way to do the latter, but since most of the#include <os/base.h>
are in API headers, that is not really an option either (since we don't want to install config.h on OSX)the best option for now may be to move the various
#include <os/base.h>
into#ifdef __APPLE__
conditionals and in the#else
case do the#include <os/linux_base.h>
(or possibly include an intermediate header that does non-APPLE platform disambiguation, though based on what ?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking about it more, something like this may make the most sense (e.g. in a new os/target.h header ?)
and then conditionalize with
#if TARGET_OS_MAC
resp.#if TARGET_OS_UNIX
?