diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | include/nsutils/assert.h | 24 | ||||
-rw-r--r-- | src/time.c | 4 |
3 files changed, 28 insertions, 3 deletions
@@ -6,7 +6,7 @@ # Component settings COMPONENT := nsutils -COMPONENT_VERSION := 0.1.0 +COMPONENT_VERSION := 0.1.1 # Default to a static library COMPONENT_TYPE ?= lib-static @@ -49,6 +49,7 @@ include $(NSBUILD)/Makefile.top # Extra installation rules I := /$(INCLUDEDIR)/nsutils +INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/nsutils/assert.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/nsutils/errors.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/nsutils/base64.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/nsutils/endian.h diff --git a/include/nsutils/assert.h b/include/nsutils/assert.h new file mode 100644 index 0000000..7f59f2f --- /dev/null +++ b/include/nsutils/assert.h @@ -0,0 +1,24 @@ +/* + * This file is part of LibNSUtils. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2022 Michael Drake <tlsa@netsurf-browser.org> + */ + +/** + * \file + * Static assertion macro. + */ + +#ifndef NSUTILS_ASSERT_H__ +#define NSUTILS_ASSERT_H__ + +/** Compile time assertion macro. */ +#define ns_static_assert(e) \ +{ \ + enum { \ + ns_static_assert_check = 1 / (!!(e)) \ + }; \ +} + +#endif @@ -20,7 +20,7 @@ #include <time.h> #elif defined(__riscos) #include <oslib/os.h> -#elif defined(__MACH__) +#elif defined(__MACH__) && defined(__APPLE__) #include <mach/mach.h> #include <mach/clock.h> #include <mach/mach_time.h> @@ -51,7 +51,7 @@ nsuerror nsu_getmonotonic_ms(uint64_t *current_out) time = os_read_monotonic_time(); current = time * 10; -#elif defined(__MACH__) +#elif defined(__MACH__) && defined(__APPLE__) clock_serv_t cclock; mach_timespec_t mts; |