diff --git a/CMakeLists.txt b/CMakeLists.txt index fdfc1e6..fa09448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.17) project(flint C) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux")) + add_compile_definitions(flint __USE_XOPEN_EXTENDED) +endif() + set(CMAKE_C_STANDARD 99) include_directories(include) @@ -21,7 +25,7 @@ set(SOURCES ) if ((${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")) - add_library(flint ${SOURCES} src/macos/macos.c) + add_library(flint ${SOURCES} src/macos.c) else() add_library(flint ${SOURCES}) endif() diff --git a/Makefile b/Makefile deleted file mode 100644 index 5aa38ee..0000000 --- a/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -.PHONY : clean tests all manual - -CFLAGS = -std=c99 -Iinclude -pedantic -WARNINGS= -Wall -Wextra -LDFLAGS = -fPIC -shared -MACROS= -D_POSIX_C_SOURCE=1 - -TARGET = libflint.so -SRC != ls src/*.c -OBJ = $(SRC:./src/$.c=./obj/%.o) - -PREFIX = $(DESTDIR)/usr/local -LIBDIR = $(PREFIX)/lib - -OS_NAME != uname -s | tr A-Z a-z - -all: $(TARGET) - ./clanggen.sh - -$(TARGET): $(OBJ) - ifeq ($(OS_NAME),"openbsd") - @echo "Building for openbsd" -endif - cc $(CFLAGS) $(WARNINGS) $(LDFLAGS) -o $(TARGET) $(OBJ) - -./obj/%.o: ./src/%.c - cc $(CFLAGS) -c $< -o $@ - -install: $(TARGET) - cp $(TARGET) $(LIBDIR) - -uninstall: - rm -f $(LIBDIR)/$(TARGET) - -clean: - rm -f $(TARGET) - rm -f testrunner - rm -f tcptest - rm -f netmanual - rm -f compile_commands.json - -tests: - cc $(CFLAGS) -o testrunner tests/tests.c src/*.c - cc $(CFLAGS) -o tcptest tests/tcptest.c src/*.c - ./run_tests.sh - -manual: - cc $(CFLAGS) -o netmanual tests/netmanual.c src/*.c - diff --git a/src/macos/macos.c b/src/macos.c similarity index 100% rename from src/macos/macos.c rename to src/macos.c diff --git a/src/network.c b/src/network.c index fa62c84..2984122 100644 --- a/src/network.c +++ b/src/network.c @@ -92,6 +92,9 @@ int serve(Server *s, int backlog_size) { return 1; } + // Linux doesn't handle SA_RESTART properly, and I don't know about Windows (nor do I care) + // This is just for macOS and BSDs + #if !defined(__linux__) && !defined(_WIN32) struct sigaction sa; sa.sa_handler = sighandler; sa.sa_flags = SA_RESTART; @@ -99,6 +102,7 @@ int serve(Server *s, int backlog_size) { fprintf(stderr, "Failed to set sigaction\n"); return 1; } + #endif s->handler(s);