Skip to content

Commit

Permalink
Merge pull request #137 from gree/feature/darwin
Browse files Browse the repository at this point in the history
Support for apple silicon
  • Loading branch information
junjihashimoto authored Feb 15, 2024
2 parents 6fa9231 + 7aa7101 commit 495c236
Show file tree
Hide file tree
Showing 14 changed files with 1,523 additions and 1,295 deletions.
2,691 changes: 1,474 additions & 1,217 deletions config.sub
100755 → 100644

Large diffs are not rendered by default.

73 changes: 15 additions & 58 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
description = "flare";

nixConfig = {
bash-prompt = "\[\\e[1m\\e[32mdev-flare\\e[0m:\\w\]$ ";
bash-prompt = "\[\\e[1m\\e[32mdev-flare\\e[0m:\\w\]\n$ ";
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?rev=2558d8e64f3816ec4291555fc8dc2212bd21f0a8";
nixpkgs.url = "github:nixos/nixpkgs?rev=fe977679240ac2027b151ecca1bc6ce808c2e8af";
flake-utils.url = "github:numtide/flake-utils";
flare-tests.url = "github:gree/flare-tests";
flare-tests.inputs.nixpkgs.follows = "nixpkgs";
flare-tests.inputs.flake-utils.follows = "flake-utils";
flare-tools.url = "github:gree/flare-tools?rev=fb5fdb35b222c894de817f406581174cd7115134";
flare-tools.url = "github:gree/flare-tools?rev=a4df2e32743bd803ed2d8ad4ba3925cbaccbdb1f";
flare-tools.inputs.nixpkgs.follows = "nixpkgs";
flare-tools.inputs.flake-utils.follows = "flake-utils";
};

outputs = { self
Expand Down
2 changes: 1 addition & 1 deletion nix/cutter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ stdenv.mkDerivation {
rev = "01af87f69c2ae7c8123fb4964dfdb520589e60f2";
hash = "sha256-tyE7jNfXZ4P7zU8m1A8jDkwqtQNNjfTQUx/Rov18rXo=";
};
buildInputs = [ autoconf automake libtool intltool glib m4 pkgconfig ];
buildInputs = [ autoconf automake libtool intltool glib m4 pkg-config ];
patches = [../cutter.patch];

buildPhase = ''
Expand Down
4 changes: 2 additions & 2 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ stdenv.mkDerivation {
zlib
libmemcached
tokyocabinet
(if system == "x86_64-darwin" then libossp_uuid else libuuid)
(if stdenv.isDarwin then libossp_uuid else libuuid)
cutter
pkgconfig
pkg-config
];

buildPhase = ''
Expand Down
2 changes: 1 addition & 1 deletion nix/emacs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

let
myEmacs = pkgs.emacs;
emacsWithPackages = (pkgs.emacsPackagesNgGen myEmacs).emacsWithPackages;
emacsWithPackages = (pkgs.emacsPackagesFor myEmacs).emacsWithPackages;
my-config = (epkgs: pkgs.emacsPackages.trivialBuild {
pname = "my-mode";
version = "2022-02-25";
Expand Down
4 changes: 2 additions & 2 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ mkShell {
zlib
libmemcached
tokyocabinet
(if system == "x86_64-darwin" then libossp_uuid else libuuid)
(if stdenv.isDarwin then libossp_uuid else libuuid)
cutter
pkgconfig
pkg-config
flare-tests
emacs-for-flare
flare-tools
Expand Down
3 changes: 3 additions & 0 deletions src/flared/flared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ int flared::_set_signal_handler() {
sigdelset(&ss, SIGTERM);
sigdelset(&ss, SIGINT);
sigdelset(&ss, SIGHUP);
#if __APPLE__
sigdelset(&ss, SIGPIPE);
#endif
if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
log_err("sigprocmask() failed: %s (%d)", util::strerror(errno), errno);
}
Expand Down
3 changes: 3 additions & 0 deletions src/flarei/flarei.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ int flarei::_set_signal_handler() {
sigdelset(&ss, SIGTERM);
sigdelset(&ss, SIGINT);
sigdelset(&ss, SIGHUP);
#if __APPLE__
sigdelset(&ss, SIGPIPE);
#endif
if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
log_err("sigprocmask() failed: %s (%d)", util::strerror(errno), errno);
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void* thread_run(void* p) {
sigset_t ss;
sigfillset(&ss);
sigdelset(&ss, SIGUSR1);
#if __APPLE__
sigdelset(&ss, SIGPIPE);
#endif
if (pthread_sigmask(SIG_SETMASK, &ss, NULL) < 0) {
log_err("pthread_sigmask() failed: %s (%d)", util::strerror(errno), errno);
}
Expand Down
12 changes: 5 additions & 7 deletions src/lib/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@
#include "util.h"
#include "thread_queue.h"

using namespace std;

namespace gree {
namespace flare {

typedef class thread thread;
typedef boost::shared_ptr<thread> shared_thread;
typedef boost::weak_ptr<thread> weak_thread;
class thread;
typedef boost::shared_ptr<gree::flare::thread> shared_thread;
typedef boost::weak_ptr<gree::flare::thread> weak_thread;

typedef class thread_pool thread_pool;
typedef class thread_handler thread_handler;
class thread_pool;
class thread_handler;

/**
* thread class
Expand Down
6 changes: 2 additions & 4 deletions src/lib/thread_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
#include "util.h"
#include "connection.h"

using namespace std;

namespace gree {
namespace flare {

typedef class thread_queue thread_queue;
typedef boost::shared_ptr<thread_queue> shared_thread_queue;
class thread_queue;
typedef boost::shared_ptr<gree::flare::thread_queue> shared_thread_queue;

/**
* thread queue base class
Expand Down
3 changes: 3 additions & 0 deletions test/lib/test_handler_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace test_handler_proxy {
log_err("sigaction for %d failed: %s (%d)", SIGUSR1, util::strerror(errno), errno);
return;
}
#if __APPLE__
signal(SIGPIPE, SIG_IGN);
#endif

stats_object = new stats();
stats_object->update_timestamp();
Expand Down
4 changes: 4 additions & 0 deletions test/lib/test_op_dump_key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ namespace test_op_dump_key
void run_server_test(test_op_dump_key& op, int item_num, int item_key_size, int bwlimit = 0, int sleep_precision = 1)
{
static const int64_t one_sec = 1000000L;
#if __APPLE__
static const int64_t epsilon = 1000000L;
#else
static const int64_t epsilon = 100000L;
#endif
struct timeval start_tv, end_tv;

gettimeofday(&start_tv, NULL);
Expand Down

0 comments on commit 495c236

Please sign in to comment.