AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START, [ echo "LIBREPLACE_CC_CHECKS: START" ]) AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END, [ echo "LIBREPLACE_CC_CHECKS: END" ]) dnl dnl dnl AC_LIBREPLACE_CC_CHECKS dnl dnl Note: we need to use m4_define instead of AC_DEFUN because dnl of the ordering of tests dnl dnl m4_define(AC_LIBREPLACE_CC_CHECKS, [ AC__LIBREPLACE_ONLY_CC_CHECKS_START dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it dnl which conflicts with C99 on HPUX ac_cv_prog_cc_Ae=no savedCFLAGS=$CFLAGS AC_PROG_CC CFLAGS=$savedCFLAGS dnl don't try for C99 if we are using gcc, as otherwise we dnl lose immediate structure constants if test x"$GCC" != x"yes" ; then AC_PROG_CC_C99 fi if test x"$GCC" = x"yes" ; then AC_MSG_CHECKING([for version of gcc]) GCC_VERSION=`$CC -dumpversion` AC_MSG_RESULT(${GCC_VERSION}) fi AC_USE_SYSTEM_EXTENSIONS AC_C_BIGENDIAN AC_C_INLINE LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) AC_PROG_INSTALL AC_ISC_POSIX AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) AC_SYS_LARGEFILE dnl Add #include for broken IRIX header files case "$host_os" in *irix6*) AC_ADD_INCLUDE() ;; *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround]) CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" fi if test "`uname -r`" = "B.11.23"; then AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" fi ;; *aix*) AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken]) if test "${GCC}" != "yes"; then ## for funky AIX compiler using strncpy() CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" fi ;; *osf*) # this brings in socklen_t AC_N_DEFINE(_XOPEN_SOURCE,600) AC_N_DEFINE(_OSF_SOURCE) ;; # # VOS may need to have POSIX support and System V compatibility enabled. # *vos*) case "$CFLAGS" in *-D_POSIX_C_SOURCE*);; *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support]) ;; esac case "$CFLAGS" in *-D_SYSV*|*-D_SVID_SOURCE*);; *) CFLAGS="$CFLAGS -D_SYSV" AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility]) ;; esac ;; esac AC_CHECK_HEADERS([standards.h]) # Solaris needs HAVE_LONG_LONG defined AC_CHECK_TYPES(long long) AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(int8_t, char) AC_CHECK_TYPE(uint8_t, unsigned char) AC_CHECK_TYPE(int16_t, short) AC_CHECK_TYPE(uint16_t, unsigned short) AC_CHECK_TYPE(int32_t, long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(int64_t, long long) AC_CHECK_TYPE(uint64_t, unsigned long long) AC_CHECK_TYPE(size_t, unsigned int) AC_CHECK_TYPE(ssize_t, int) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(ssize_t) AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(ptrdiff_t, unsigned long long) if test x"$ac_cv_type_long_long" != x"yes";then AC_MSG_ERROR([LIBREPLACE needs type 'long long']) fi if test $ac_cv_sizeof_long_long -lt 8;then AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8]) fi ############################################ # check if the compiler can do immediate structures AC_SUBST(libreplace_cv_immediate_structures) AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ AC_TRY_COMPILE([ #include ],[ typedef struct {unsigned x;} FOOBAR; #define X_FOOBAR(x) ((FOOBAR) { x }) #define FOO_ONE X_FOOBAR(1) FOOBAR f = FOO_ONE; static const struct { FOOBAR y; } f2[] = { {FOO_ONE} }; ], libreplace_cv_immediate_structures=yes, libreplace_cv_immediate_structures=no, libreplace_cv_immediate_structures=cross) ]) if test x"$libreplace_cv_immediate_structures" = x"yes"; then AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) fi AC__LIBREPLACE_ONLY_CC_CHECKS_END ]) dnl end AC_LIBREPLACE_CC_CHECKS > 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
/* Definition of the batch_t data structure.
 * I am not sure yet if this will become a full-blown object. For now, this header just
 * includes the object definition and is not accompanied by code.
 *
 * Copyright 2009 by Rainer Gerhards and Adiscon GmbH.
 *
 * This file is part of the rsyslog runtime library.
 *
 * The rsyslog runtime library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The rsyslog runtime library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the rsyslog runtime library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
 */

#ifndef BATCH_H_INCLUDED
#define BATCH_H_INCLUDED

/* enum for batch states. Actually, we violate a layer here, in that we assume that a batch is used
 * for action processing. So far, this seems acceptable, the status is simply ignored inside the
 * main message queue. But over time, it could potentially be useful to split the two.
 * rgerhad, 2009-05-12
 */
typedef enum {
	BATCH_STATE_RDY  = 0,	/* object ready for processing */
	BATCH_STATE_BAD  = 1,	/* unrecoverable failure while processing, do NOT resubmit to same action */
	BATCH_STATE_SUB  = 2,	/* message submitted for processing, outcome yet unkonwn */
	BATCH_STATE_COMM = 3,	/* message successfully commited */
	BATCH_STATE_DISC = 4, 	/* discarded - processed OK, but do not submit to any other action */
} batch_state_t;


/* an object inside a batch, including any information (state!) needed for it to "life".
 */
struct batch_obj_s {
	obj_t *pUsrp;		/* pointer to user object (most often message) */
	batch_state_t state;	/* associated state */
};

/* the batch
 * This object is used to dequeue multiple user pointers which are than handed over
 * to processing. The size of elements is fixed after queue creation, but may be 
 * modified by config variables (better said: queue properties).
 * Note that a "user pointer" in rsyslog context so far always is a message 
 * object. We stick to the more generic term because queues may potentially hold
 * other types of objects, too.
 * rgerhards, 2009-05-12
 * Note that nElem is not necessarily equal to nElemDeq. This is the case when we
 * discard some elements (because of configuration) during dequeue processing. As
 * all Elements are only deleted when the batch is processed, we can not immediately
 * delete them. So we need to keep their number that we can delete them when the batch
 * is completed (else, the whole process does not work correctly).
 */
struct batch_s {
	int nElem;		/* actual number of element in this entry */
	int nElemDeq;		/* actual number of elements dequeued (and thus to be deleted) - see comment above! */
	int iDoneUpTo;		/* all messages below this index have state other than RDY */