Skip to content

Add FreeBSD support#670

Open
vkrivopalov wants to merge 1 commit intoTelegramMessenger:masterfrom
vkrivopalov:freebsd-support
Open

Add FreeBSD support#670
vkrivopalov wants to merge 1 commit intoTelegramMessenger:masterfrom
vkrivopalov:freebsd-support

Conversation

@vkrivopalov
Copy link

Port MTProxy to FreeBSD by addressing Linux-specific dependencies:

Build system (Makefile):

  • Add FreeBSD detection and platform-specific CFLAGS/LDFLAGS
  • Link against libepoll-shim for epoll compatibility layer
  • Link against libexecinfo for backtrace support
  • Remove -lrt and -rdynamic (not needed on FreeBSD)

Signal handling:

  • Add missing signal.h include in mtproto-proxy.c
  • Adapt SIGRTMAX handling for FreeBSD (uses different signal range)
  • Wrap SIGPOLL usage (not available on FreeBSD)

Threading and synchronization:

  • Replace Linux futex syscalls with FreeBSD _umtx_op()
  • Replace SYS_gettid with thr_self() for thread identification
  • Replace glibc-specific drand48_r/srand48_r with mutex-protected standard drand48/srand48 functions
  • Wrap struct drand48_data with #ifdef linux

Socket options:

  • Wrap TCP_WINDOW_CLAMP (Linux-specific)
  • Wrap TCP_QUICKACK (Linux-specific)
  • Wrap IP_RECVERR/SOL_IP (Linux-specific)

Header compatibility:

  • Disable _XOPEN_SOURCE on FreeBSD (conflicts with IPv6 definitions)
  • Add sys/socket.h before netinet/in.h for struct sockaddr_in6
  • Add socket headers to resolver.c
  • Wrap sys/io.h include (Linux-specific)
  • Undef close macro from libepoll-shim to avoid struct member conflict

Compiler compatibility:

  • Add clang-compatible intrinsic macros for SIMD operations in crc32.c (maps GCC _builtin_ia32* to standard Intel intrinsics)

Requires: libepoll-shim package (pkg install libepoll-shim)

Use 'gmake' (pkg install gmake) to stay compatible with GNU-style Makefile.

Closes: #16 #331

Port MTProxy to FreeBSD by addressing Linux-specific dependencies:

Build system (Makefile):
- Add FreeBSD detection and platform-specific CFLAGS/LDFLAGS
- Link against libepoll-shim for epoll compatibility layer
- Link against libexecinfo for backtrace support
- Remove -lrt and -rdynamic (not needed on FreeBSD)

Signal handling:
- Add missing signal.h include in mtproto-proxy.c
- Adapt SIGRTMAX handling for FreeBSD (uses different signal range)
- Wrap SIGPOLL usage (not available on FreeBSD)

Threading and synchronization:
- Replace Linux futex syscalls with FreeBSD _umtx_op()
- Replace SYS_gettid with thr_self() for thread identification
- Replace glibc-specific drand48_r/srand48_r with mutex-protected
  standard drand48/srand48 functions
- Wrap struct drand48_data with #ifdef __linux__

Socket options:
- Wrap TCP_WINDOW_CLAMP (Linux-specific)
- Wrap TCP_QUICKACK (Linux-specific)
- Wrap IP_RECVERR/SOL_IP (Linux-specific)

Header compatibility:
- Disable _XOPEN_SOURCE on FreeBSD (conflicts with IPv6 definitions)
- Add sys/socket.h before netinet/in.h for struct sockaddr_in6
- Add socket headers to resolver.c
- Wrap sys/io.h include (Linux-specific)
- Undef close macro from libepoll-shim to avoid struct member conflict

Compiler compatibility:
- Add clang-compatible intrinsic macros for SIMD operations in crc32.c
  (maps GCC __builtin_ia32_* to standard Intel intrinsics)

Requires: libepoll-shim package (pkg install libepoll-shim)

Use 'gmake' (pkg install gmake) to stay compatible with GNU-style
Makefile.

Signed-off-by: Vladimir Krivopalov <vladimir.krivopalov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build error on Solaris

1 participant