prepare v1.1.4
[awesomized/libmemcached] / src / libmemcached / common.h
index defb3b0da19b31ab7b79662e3d6e5c2bc9111dd3..ed12d617fad5d74424b9caceaa21b6e19d5e1d8a 100644 (file)
@@ -1,6 +1,6 @@
 /*
     +--------------------------------------------------------------------+
-    | libmemcached - C/C++ Client Library for memcached                  |
+    | libmemcached-awesome - C/C++ Client Library for memcached          |
     +--------------------------------------------------------------------+
     | Redistribution and use in source and binary forms, with or without |
     | modification, are permitted under the terms of the BSD license.    |
@@ -9,7 +9,7 @@
     | the terms online at: https://opensource.org/licenses/BSD-3-Clause  |
     +--------------------------------------------------------------------+
     | Copyright (c) 2006-2014 Brian Aker   https://datadifferential.com/ |
-    | Copyright (c) 2020 Michael Wallner   <mike@php.net>                |
+    | Copyright (c) 2020-2021 Michael Wallner        https://awesome.co/ |
     +--------------------------------------------------------------------+
 */
 
 #  include <iso646.h>
 #endif
 
-#ifdef HAVE_SYS_UN_H
-#  include <sys/un.h>
-#endif
+#include "p9y/socket.hpp"
 
 #ifdef HAVE_SYS_TIME_H
 #  include <sys/time.h>
 #endif
 
 #include <fcntl.h>
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
 
 #ifdef HAVE_STRINGS_H
 #  include <strings.h>
@@ -151,11 +140,21 @@ static inline void memcached_server_response_increment(memcached_instance_st *in
 }
 #endif
 
-#define memcached_server_response_decrement(A) (A)->cursor_active_--
-#define memcached_server_response_reset(A)     (A)->cursor_active_ = 0
+#define memcached_server_response_decrement(A) do {     \
+    WATCHPOINT_ASSERT((A)->cursor_active_ > 0);         \
+    if ((A)->cursor_active_ > 0) {                      \
+        (A)->cursor_active_--;                          \
+    }                                                   \
+} while (0)
+#define memcached_server_response_reset(A)       (A)->cursor_active_ = 0
 
 #define memcached_instance_response_increment(A) (A)->cursor_active_++
-#define memcached_instance_response_decrement(A) (A)->cursor_active_--
+#define memcached_instance_response_decrement(A) do {   \
+    WATCHPOINT_ASSERT((A)->cursor_active_ > 0);         \
+    if ((A)->cursor_active_ > 0) {                      \
+        (A)->cursor_active_--;                          \
+    }                                                   \
+} while (0)
 #define memcached_instance_response_reset(A)     (A)->cursor_active_ = 0
 
 #ifdef __cplusplus