Open SCAP Library
/home/pvrabec/project/openscap/openscap-0.8.0/src/OVAL/probes/probe/icache.h
00001 /*
00002  * Copyright 2011 Red Hat Inc., Durham, North Carolina.
00003  * All Rights Reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  * Authors:
00020  *      Daniel Kopecek <dkopecek@redhat.com>
00021  */
00022 #ifndef ICACHE_H
00023 #define ICACHE_H
00024 
00025 #include <stddef.h>
00026 #include <sexp.h>
00027 #include "../SEAP/generic/rbt/rbt.h"
00028 
00029 #ifndef PROBE_IQUEUE_CAPACITY
00030 #define PROBE_IQUEUE_CAPACITY 1024
00031 #endif
00032 
00033 typedef struct {
00034         SEXP_t *cobj;
00035         union {
00036                 SEXP_t         *item;
00037                 pthread_cond_t *cond;
00038         } p;
00039 } probe_iqpair_t;
00040 
00041 typedef struct {
00042         rbt_t    *tree; /* XXX: rewrite to extensible or linear hashing */
00043         pthread_t thid;
00044 
00045         pthread_mutex_t queue_mutex;
00046         pthread_cond_t  queue_notempty;
00047         pthread_cond_t  queue_notfull;
00048 
00049         probe_iqpair_t  queue[PROBE_IQUEUE_CAPACITY];
00050         uint16_t        queue_beg;
00051         uint16_t        queue_end;
00052         uint16_t        queue_cnt;
00053         uint16_t        queue_max;
00054 } probe_icache_t;
00055 
00056 typedef struct {
00057         SEXP_t  **item;
00058         uint16_t  count;
00059 } probe_citem_t;
00060 
00061 probe_icache_t *probe_icache_new(void);
00062 int probe_icache_add(probe_icache_t *cache, SEXP_t *cobj, SEXP_t *item);
00063 int probe_icache_nop(probe_icache_t *cache);
00064 void probe_icache_free(probe_icache_t *cache);
00065 
00066 #endif /* ICACHE_H */