Diff for /libelwix/inc/elwix.h between versions 1.23.4.1 and 1.32.4.2

version 1.23.4.1, 2024/06/10 16:02:28 version 1.32.4.2, 2026/07/29 01:09:33
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004 - 2024Copyright 2004 - 2026
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 47  SUCH DAMAGE. Line 47  SUCH DAMAGE.
 #define __ELWIX_H  #define __ELWIX_H
   
   
   #include <stdio.h>
 #include <assert.h>  #include <assert.h>
 #include <syslog.h>  #include <syslog.h>
 #include <stdarg.h>  #include <stdarg.h>
   #include <stdalign.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/un.h>  #include <sys/un.h>
   #ifndef __cplusplus
           #include <stdatomic.h>
   #else
           #include <atomic>
           #define _Atomic(X) std::atomic<X>
   #endif
 #ifndef __linux__  #ifndef __linux__
 #include <sys/limits.h>  #include <sys/limits.h>
 #include <sys/endian.h>  #include <sys/endian.h>
Line 81  SUCH DAMAGE. Line 89  SUCH DAMAGE.
 #include <elwix/ajson.h>  #include <elwix/ajson.h>
 #include <elwix/aiov.h>  #include <elwix/aiov.h>
 #include <elwix/aindex.h>  #include <elwix/aindex.h>
   #include <elwix/aring.h>
   #include <elwix/auuid.h>
   
   
 #ifndef STRSIZ  #ifndef STRSIZ
Line 161  SUCH DAMAGE. Line 171  SUCH DAMAGE.
 #define powerof2(x)             ((((x) - 1) & (x)) == 0)  #define powerof2(x)             ((((x) - 1) & (x)) == 0)
 #endif  #endif
   
   /* timespec helpers */
   /* Operations on timevals. */
   #ifndef timerclear
   #define timerclear(tvp)         ((tvp)->tv_sec = (tvp)->tv_usec = 0)
   #endif
   
   #ifndef timerisset
   #define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
   #endif
   
   #ifndef timercmp
   #define timercmp(tvp, uvp, cmp)                                         \
           (((tvp)->tv_sec == (uvp)->tv_sec) ?                             \
               ((tvp)->tv_usec cmp (uvp)->tv_usec) :                       \
               ((tvp)->tv_sec cmp (uvp)->tv_sec))
   #endif
   
   #ifndef timeradd
   #define timeradd(tvp, uvp, vvp)                                         \
           do {                                                            \
                   (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
                   (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
                   if ((vvp)->tv_usec >= 1000000) {                        \
                           (vvp)->tv_sec++;                                \
                           (vvp)->tv_usec -= 1000000;                      \
                   }                                                       \
           } while (0)
   #endif
   
   #ifndef timersub
   #define timersub(tvp, uvp, vvp)                                         \
           do {                                                            \
                   (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
                   (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
                   if ((vvp)->tv_usec < 0) {                               \
                           (vvp)->tv_sec--;                                \
                           (vvp)->tv_usec += 1000000;                      \
                   }                                                       \
           } while (0)
   #endif
   
   /* Operations on timespecs. */
   #ifndef timespecclear
   #define timespecclear(tsp)              ((tsp)->tv_sec = (tsp)->tv_nsec = 0)
   #endif
   
   #ifndef timespecisset
   #define timespecisset(tsp)              ((tsp)->tv_sec || (tsp)->tv_nsec)
   #endif
   
   #ifndef timespeccmp
   #define timespeccmp(tsp, usp, cmp)                                      \
           (((tsp)->tv_sec == (usp)->tv_sec) ?                             \
               ((tsp)->tv_nsec cmp (usp)->tv_nsec) :                       \
               ((tsp)->tv_sec cmp (usp)->tv_sec))
   #endif
   
   #ifndef timespecadd
   #define timespecadd(tsp, usp, vsp)                                      \
           do {                                                            \
                   (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;          \
                   (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;       \
                   if ((vsp)->tv_nsec >= 1000000000L) {                    \
                           (vsp)->tv_sec++;                                \
                           (vsp)->tv_nsec -= 1000000000L;                  \
                   }                                                       \
           } while (0)
   #endif
   
   #ifndef timespecsub
   #define timespecsub(tsp, usp, vsp)                                      \
           do {                                                            \
                   (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;          \
                   (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;       \
                   if ((vsp)->tv_nsec < 0) {                               \
                           (vsp)->tv_sec--;                                \
                           (vsp)->tv_nsec += 1000000000L;                  \
                   }                                                       \
           } while (0)
   #endif
   
 /* Macros for min/max. */  /* Macros for min/max. */
 #ifndef MIN  #ifndef MIN
 #define MIN(a, b)               (((a) < (b)) ? (a) : (b))  #define MIN(a, b)               (((a) < (b)) ? (a) : (b))
Line 179  SUCH DAMAGE. Line 270  SUCH DAMAGE.
 #define VACUUM_BETWEEN          2  #define VACUUM_BETWEEN          2
   
   
extern int __isthreaded;typedef struct {
         E_ATOMIC_ALIGN int    value;
 } e_atomic_int;
   
   #ifdef __cplusplus
   extern "C" {
   #endif
   
   extern int __isthreaded;
   
 // elwix_SetProg() Set program memory pool name  // elwix_SetProg() Set program memory pool name
 void elwix_SetProg(const char *csProgName);  void elwix_SetProg(const char *csProgName);
 // elwix_GetProg() Get program memory pool name  // elwix_GetProg() Get program memory pool name
Line 258  extern int elwix_Verbose; Line 356  extern int elwix_Verbose;
 #define EVERBS(x)               if ((x) <= elwix_Verbose)  #define EVERBS(x)               if ((x) <= elwix_Verbose)
 #define EVERBOSE(x, fmt, ...)   do { assert((fmt)); \  #define EVERBOSE(x, fmt, ...)   do { assert((fmt)); \
                                         if ((x) <= elwix_Verbose) { \                                          if ((x) <= elwix_Verbose) { \
                                                char __str[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; \                                                char __str[BUFSIZ] = { 0 }; \
                                                 snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                                  snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                                 syslog(LOG_INFO, "Verbose(%d):%s(%d): %s\n", \                                                  syslog(LOG_INFO, "Verbose(%d):%s(%d): %s\n", \
                                                                 (x), __func__, __LINE__, __str); \                                                                  (x), __func__, __LINE__, __str); \
Line 266  extern int elwix_Verbose; Line 364  extern int elwix_Verbose;
                                 } while (0)                                  } while (0)
 #define EVERBOSE2(x, fmt, ...)  do { assert((fmt)); \  #define EVERBOSE2(x, fmt, ...)  do { assert((fmt)); \
                                         if ((x) <= elwix_Verbose) { \                                          if ((x) <= elwix_Verbose) { \
                                                char __str[0x10000] = { [0 ... 0xffff] = 0 }; \                                                char __str[0x10000] = { 0 }; \
                                                 snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                                  snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                                 syslog(LOG_INFO, "Verbose(%d):%s(%d): %s\n", \                                                  syslog(LOG_INFO, "Verbose(%d):%s(%d): %s\n", \
                                                                 (x), __func__, __LINE__, __str); \                                                                  (x), __func__, __LINE__, __str); \
Line 287  extern int elwix_Debug; Line 385  extern int elwix_Debug;
 #define ELWIX_DEBUG_LOCK        0x20  #define ELWIX_DEBUG_LOCK        0x20
 #define ELWIX_DEBUG_SYS         0x40  #define ELWIX_DEBUG_SYS         0x40
 #define ELWIX_DEBUG_NET         0x80  #define ELWIX_DEBUG_NET         0x80
   #define ELWIX_DEBUG_1           0x100
   #define ELWIX_DEBUG_2           0x200
   #define ELWIX_DEBUG_3           0x400
   #define ELWIX_DEBUG_4           0x800
 #define ELWIX_DEBUG_ANY         0xFFFFFFFF  #define ELWIX_DEBUG_ANY         0xFFFFFFFF
   
 #define EDBG(x)                 (elwix_Debug & (x))  #define EDBG(x)                 (elwix_Debug & (x))
Line 295  extern int elwix_Debug; Line 397  extern int elwix_Debug;
                                            syslog(LOG_DEBUG, "I'm in %s(%d)\n", __func__, __LINE__)                                             syslog(LOG_DEBUG, "I'm in %s(%d)\n", __func__, __LINE__)
 #define EDEBUG(x, fmt, ...)     do { assert((fmt)); \  #define EDEBUG(x, fmt, ...)     do { assert((fmt)); \
                                         if ((x) & elwix_Debug) { \                                          if ((x) & elwix_Debug) { \
                                                char __str[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; \                                                char __str[BUFSIZ] = { 0 }; \
                                                 snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                                  snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                                 syslog(LOG_DEBUG, "Debug(%d):%s(%d): %s\n", \                                                  syslog(LOG_DEBUG, "Debug(%d):%s(%d): %s\n", \
                                                                 (x), __func__, __LINE__, __str); \                                                                  (x), __func__, __LINE__, __str); \
Line 304  extern int elwix_Debug; Line 406  extern int elwix_Debug;
   
 /* Logger macro */  /* Logger macro */
 #define ELOGGER(x, fmt, ...)    do { assert((fmt)); \  #define ELOGGER(x, fmt, ...)    do { assert((fmt)); \
                                        char __str[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; \                                        char __str[BUFSIZ] = { 0 }; \
                                         snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                          snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                        syslog((x), "Logger:%s(%d): %s\n", \                                        syslog((x), "Log:%s(%d): %s\n", \
                                                                 __func__, __LINE__, __str); \                                                                  __func__, __LINE__, __str); \
                                 } while (0)                                  } while (0)
   
 #define EWARNING(x, fmt, ...)   do { assert((fmt)); \  #define EWARNING(x, fmt, ...)   do { assert((fmt)); \
                                        char __str[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; \                                        char __str[BUFSIZ] = { 0 }; \
                                         snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                          snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                         syslog(LOG_WARNING, "Warning:%s(%d): #%d - %s\n", \                                          syslog(LOG_WARNING, "Warning:%s(%d): #%d - %s\n", \
                                                          __func__, __LINE__, (x), __str); \                                                           __func__, __LINE__, (x), __str); \
                                 } while (0)                                  } while (0)
 /* Error state macros */  /* Error state macros */
 #define EERROR(x, fmt, ...)     do { assert((fmt)); \  #define EERROR(x, fmt, ...)     do { assert((fmt)); \
                                        char __str[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; \                                        char __str[BUFSIZ] = { 0 }; \
                                         snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \                                          snprintf(__str, sizeof __str, (fmt), ##__VA_ARGS__); \
                                         syslog(LOG_ERR, "Error:%s(%d): #%d - %s\n", \                                          syslog(LOG_ERR, "Error:%s(%d): #%d - %s\n", \
                                                          __func__, __LINE__, (x), __str); \                                                           __func__, __LINE__, (x), __str); \
Line 339  extern int elwix_Debug; Line 441  extern int elwix_Debug;
                                                                 ait##_GetError()); \                                                                  ait##_GetError()); \
                                 } while (0)                                  } while (0)
   
   
   #ifdef __cplusplus
   }
   #endif
   
 #endif  #endif

Removed from v.1.23.4.1  
changed lines
  Added in v.1.32.4.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>