Files
Jungfraujoch/common/ZMQWrappers.h
T
leonarski_f 6a21d453ba macOS groundwork: what a static read says will stop an Apple Clang / libc++ build
None of this has been built on a Mac - there is none yet. It is the list a read-only audit of the
viewer/rugnux subtree produced, plus a serial -fsyntax-only pass of every reachable .cpp with
clang 16 + libc++ on Linux, which found exactly one error (the first item).

- JFJochDatasetInfoChartView: std::vector<fftwf_complex> does not compile with libc++, whose
  construct_at refuses an array element type (float[2]). Use std::vector<std::complex<float>> and
  the reinterpret_cast every other FFTW call site already uses.
- libcurl: GSSAPI off on Linux, and neither TLS nor GSSAPI on macOS. The viewer never sets
  CURLOPT_HTTPAUTH, so Negotiate was dead weight that cost a krb5-devel build dependency; on macOS
  curl's FindGSS refuses the system Heimdal outright, and with Secure Transport gone from curl
  (8.15) TLS would mean a Homebrew OpenSSL - the only host library a Mac build would need.
  Linux keeps OpenSSL. CURL_USE_GSSAPI is forced OFF rather than left unset so an existing build
  tree drops its cached ON.
- libjpeg-turbo ExternalProject: CMAKE_SYSTEM_NAME/PROCESSOR were forwarded unconditionally, which
  puts even a native sub-build into cross-compiling mode, and CMAKE_OSX_ARCHITECTURES / SYSROOT /
  DEPLOYMENT_TARGET were not forwarded at all. Now the same rule the zlib-ng sub-build follows.
- ShadowAccumulatorGPU.cu was added on the JFJOCH_USE_CUDA option (default ON) instead of
  JFJOCH_CUDA_AVAILABLE like every other .cu, so a machine without nvcc got a CUDA source in a
  target with no CUDA language.
- CMAKE_OSX_DEPLOYMENT_TARGET defaults to 12.0 (overridable). Left unset, CMake takes the build
  machine's OS version and the .dmg starts nowhere older.
- Standard headers that were only arriving transitively (<chrono>, <cmath>, <limits>, <cstring>,
  <atomic>, <thread>, <string>); newer libc++ releases keep removing such transitive includes.

Checked: the seven changed sources pass clang 16 + libc++ -fsyntax-only. The CMake changes are
not configured or built.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015eAE2K7i5JGDwgwifiCfuA
(cherry picked from commit 5a7282759a)
2026-09-20 18:45:04 +02:00

84 lines
2.5 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <chrono>
#include <string>
#include <vector>
#include <thread>
#include <mutex>
#include <zmq.h>
#include "JFJochException.h"
class ZMQContext {
void *context;
public:
ZMQContext();
ZMQContext& NumThreads(int32_t threads);
~ZMQContext();
void *GetContext() const;
};
enum class ZMQSocketType : int {Push = ZMQ_PUSH, Pull = ZMQ_PULL, Req = ZMQ_REQ, Rep = ZMQ_REP,
Pub = ZMQ_PUB, Sub = ZMQ_SUB};
class ZMQMessage {
zmq_msg_t msg;
public:
ZMQMessage();
~ZMQMessage();
ZMQMessage(ZMQMessage &other) = delete;
ZMQMessage& operator=(ZMQMessage &other) = delete;
zmq_msg_t *GetMsg();
size_t size();
const uint8_t *data();
};
class ZMQSocket {
std::mutex m;
ZMQContext context;
ZMQSocketType socket_type;
void *socket;
void SetSocketOption(int32_t option_name, int32_t value);
public:
ZMQSocket(ZMQSocket &socket) = delete;
const ZMQSocket& operator=(ZMQSocket &socket) = delete;
explicit ZMQSocket(ZMQSocketType socket_type);
~ZMQSocket();
void Connect(const std::string& addr);
void Disconnect(const std::string& addr);
void Bind(const std::string& addr);
ZMQSocket &NoReceiveTimeout();
ZMQSocket &ReceiveTimeout(std::chrono::milliseconds input);
ZMQSocket &NoSendTimeout();
ZMQSocket &SendTimeout(std::chrono::milliseconds input);
ZMQSocket &Subscribe(const std::string &topic);
ZMQSocket &SubscribeAll();
ZMQSocket &NoLinger();
ZMQSocket &Conflate(bool input);
ZMQSocket &SendBufferSize(int32_t bytes);
ZMQSocket &ReceiverBufferSize(int32_t bytes);
bool Receive(ZMQMessage& msg, bool blocking = true);
void Send();
bool Send(const void *buf, size_t buf_size, bool blocking = true, bool multipart = false);
bool SendZeroCopy(void *data, size_t size,void (*callback)(void *, void *), void *hint, bool blocking = true);
template <class T> bool Send(const std::vector<T> &buf) {
return Send(buf.data(), buf.size() * sizeof(T));
}
void Send(const int32_t &value);
bool Send(const std::string &s, bool blocking = true, bool multipart = false);
void Send(zmq_msg_t *msg);
ZMQSocket &SendWaterMark(int32_t msgs);
ZMQSocket &ReceiveWaterMark(int32_t msgs);
ZMQSocket &EnableKeepAlive();
std::string GetEndpointName();
};