Commit Graph

60 Commits

Author SHA1 Message Date
Allan Odgaard
d3b857ba05 Revert "Use thread_local instead of our own implementation"
This reverts commit 1658d6356a.
2016-10-03 22:09:10 +02:00
Ronald Wampler
1658d6356a Use thread_local instead of our own implementation
Apple's clang (Apple LLVM version 8.0.0 (clang-800.0.24.1)) as shipped with Xcode 8 now supports `thread_local`. This effectively reverts commits: 14c6a70 f3d1aba 9d1d1a1a and 172ce9d.
2016-09-15 07:17:52 +02:00
Allan Odgaard
46fb745bbe Use perrorf when printing errors with dynamic strings
Also revise error messages to be more consistent.
2016-08-28 17:25:26 +02:00
Allan Odgaard
fe301508c8 Introduce perrorf as shorthand for fprintf with strerror 2016-08-28 17:25:19 +02:00
Allan Odgaard
dbdfa3c6af Add identifying information to perror output 2016-08-21 12:09:30 +02:00
Allan Odgaard
a415576827 Disable deprecation warning for Gestalt API
The replacement API¹ did not appear until the 10.10 SDK, although it might be usable from 10.9.2, but as we currently support 10.8, we cannot use it.

¹ [[NSProcessInfo processInfo] operatingSystemVersion]
2016-07-05 10:45:02 +02:00
Allan Odgaard
96508d81c3 Remove unused function (os_tuple) 2016-06-22 20:44:41 +02:00
Allan Odgaard
437f640e74 Implement move assignment and constructor for oak::basic_tree_t 2016-06-20 18:19:13 +02:00
Allan Odgaard
8e8a647e25 Add algorithm to erase descendent keys form a std::map
This can be used when the key is name spaced, e.g. `/foo/bar` or `foo.bar`. Here we can erase everything under foo by using `/foo/` or `foo.` respectively.
2016-06-02 21:07:43 +02:00
Ronald Wampler
f3d1abaeca Introduce tls_ptr_t
This is a lightweight wrapper around the pthread methods to access thread local memory.
2015-08-11 21:01:07 +02:00
Allan Odgaard
457969788e Use std::tuple for the OS version
This makes compatibility checks simpler, since we can use a single comparison operator.
2015-06-23 22:46:58 +02:00
Allan Odgaard
29a576ffbe Don’t go via helper for pthread_setname_np
This was previously done because the function wasn’t available until 10.7, but since that is (now) our deployment target, there is no need to wrap the call.
2014-12-25 09:36:01 +01:00
Allan Odgaard
0bdefafac3 Remove dependency graph support to only framework using this API 2014-12-25 09:33:56 +01:00
Allan Odgaard
aeb9ab7d00 Move server.h to the only framework left using this legacy API 2014-12-25 09:33:13 +01:00
Allan Odgaard
0c99cb0699 Remove unused helper function 2014-12-25 09:32:23 +01:00
Allan Odgaard
7cb2330aae Log error if curl_easy_init() or accept() fails 2014-09-30 14:15:11 +02:00
Allan Odgaard
ec81a045af Force a layout before opening window (from tests)
This appears to be a requirement (to do it manually). Running 10.9.4.
2014-09-17 10:35:25 +02:00
Allan Odgaard
57e43f27e3 Return 0 if Gestalt() fails 2014-08-21 16:06:33 +02:00
Allan Odgaard
c272afaff2 Cleanup/harmonize whitespace
Leading indent should consist only of tabs, beyond that, only spaces should be used.
2014-04-25 16:55:31 +07:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +07:00
Allan Odgaard
10d94644f7 Switch oak::server_t implementation from pthread → libdispatch
This makes the abstraction redundant and it should be removed. I am doing that as a multi-step process, since the previous implementation was blocking tests from being updated to the new (dispatch queue based) test system.
2014-04-08 15:43:20 +07:00
Allan Odgaard
69c83e56df The ‘const’ keyword should be to the right of its type
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.

E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
2014-03-31 08:27:19 +07:00
Allan Odgaard
2c20ab23b0 Ask for maximum queue length for pending socket connections
This is mainly because the SOMAXCONN constant looks better (in the source) than some arbitrarily chosen number. The constant is presently defined as 128 so it doesn’t seem wasteful, and presumably the queue will only take up space if we are not actually responding to socket connections.
2014-03-23 22:47:16 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
02e64d17e6 Remove unused operation queue type 2013-09-03 12:27:20 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
374f8a2248 Make oak::callbacks_t somewhat thread safe
If we only add, remove, and signal callbacks, the data type is now thread safe. This is mainly for the purpose of the concurrent tests.
2013-08-24 01:19:29 +02:00
Allan Odgaard
7a12fd1c41 Don’t define global macros that are only used in QuickLook target 2013-08-16 22:40:07 +02:00
Allan Odgaard
b25f716f86 Remove rforeach macro 2013-08-12 19:32:23 +02:00
Allan Odgaard
12067e806a Don’t keep mutex locked when calling client code
The mutex was locked to ensure that the client object did not go away, but the client’s code may terminate the program which destroys the server_t instance and thereby the mutex itself, which would previously cause an assertion to trigger, since the mutex was locked during destruction.

In practice there is no issue with the mutex not being locked while accessing the client object, as “unregister_client” and “master_run” are both called from the main thread, except for tests, but here we do not unregister client objects before their requests have been handled.
2013-08-12 19:32:23 +02:00
Allan Odgaard
2ad42430c4 Make client API for oak::server_t thread safe 2013-08-05 11:17:04 +02:00
Allan Odgaard
c3a6294806 Use std::function instead of templated argument 2013-08-03 17:22:01 +02:00
Allan Odgaard
84ef9bb768 Use std::transform instead of custom code 2013-08-03 13:22:03 +02:00
Allan Odgaard
84dc2dd871 Allow a target to use both new and old test system
Presently the new test system cannot be used for (interactive) GUI tests, so we keep the old one until we have that feature in the new.
2013-08-01 19:01:24 +02:00
Jacob Bandes-Storch
17e822896e Add Quick Look generator
Closes #1062
2013-07-30 23:11:49 +02:00
Allan Odgaard
d5d01542f7 Support copying test::jail_t 2013-07-25 13:54:25 +02:00
Allan Odgaard
eb1acfe70f Remove box_layout.h header (unused) 2013-06-28 08:42:06 +02:00
Allan Odgaard
58cfa20a1b Add operator<< for std::map
This is to allow chaining inserts and to avoid temporary variables when inserting maps returned from functions.
2013-05-12 11:09:16 +07:00
Allan Odgaard
b489687403 Disable AuthorizationExecuteWithPrivileges deprecation warning
The “proper” replacement for this API is to use the ServiceManagement framework’s SMJobBless() to bless our helper tool. In two of the three use-cases our helper tool is however regular shell commands, so it seems redundant to wrap these shell tools as helper tools we can install as launchd jobs.
2013-05-06 14:51:31 +07:00
Allan Odgaard
398e55cdbe Add helper functions to get OS version
We need this in a few places and while calling Gestalt() isn’t that much code, that function is deprecated in 10.8 and the alternative is a lot more code, so we don’t want to repeat that once we update the code.
2013-03-17 15:44:06 +01:00
Allan Odgaard
d18b30f280 Remove oak::lock_t and oak::mutex_t 2013-03-13 12:37:21 +01:00
Allan Odgaard
13edc6d131 Use O_CLOEXEC when opening files
This avoids leaking file descriptors into child processes, which would otherwise happen if another thread forks while the file descriptor is open.
2013-03-10 16:07:10 +01:00
Allan Odgaard
090a6ac698 Increase queue size for test (web) server
With concurrent tests and sequential handling of requests, the queue size is likely to grow to “number of concurrent tests”.
2013-03-10 16:07:10 +01:00
Allan Odgaard
eb893105e4 Disallow copying test::jail_t
Since we delete the jailed directory in the destructor we can’t support a deep copy of this type. Since we don’t need it, and it’s just a type used in tests, I opted for simply disabling this (to get a compiler error, should it be attempted) rather than introduce the necessary code to allow shallow copies.
2013-02-25 15:26:41 +01:00
Allan Odgaard
4712515e8b Allow passing a window to OakSetupApplicationWithView
Should rename the function to reflect this new flexibility.
2013-02-04 19:38:31 +01:00
Allan Odgaard
701c9a0541 Use ‘std’ namespace prefix when calling search()
This is to avoid a clash with other things named ‘search’.
2012-12-28 02:47:19 +01:00
Allan Odgaard
452c0b3889 Make cocoa.h usable with ARC
This means removing a few autoreleases so it’ll leak when building without ARC, but as this is just for a short-lived test, it shouldn’t matter.
2012-09-24 20:58:42 +02:00
Allan Odgaard
a94e89d7be Remove code for beginof/endof 2012-09-20 12:22:21 +02:00
Allan Odgaard
0f3861fec7 Retire custom begin/endof functions
We can now use std::begin/end although for containers we explicitly call the member functions.
2012-09-20 12:22:21 +02:00