Blame tools/fpgad/fpgad.h

Packit Service 3975d1
// Copyright(c) 2018-2020, Intel Corporation
Packit Service 3975d1
//
Packit Service 3975d1
// Redistribution  and  use  in source  and  binary  forms,  with  or  without
Packit Service 3975d1
// modification, are permitted provided that the following conditions are met:
Packit Service 3975d1
//
Packit Service 3975d1
// * Redistributions of  source code  must retain the  above copyright notice,
Packit Service 3975d1
//   this list of conditions and the following disclaimer.
Packit Service 3975d1
// * Redistributions in binary form must reproduce the above copyright notice,
Packit Service 3975d1
//   this list of conditions and the following disclaimer in the documentation
Packit Service 3975d1
//   and/or other materials provided with the distribution.
Packit Service 3975d1
// * Neither the name  of Intel Corporation  nor the names of its contributors
Packit Service 3975d1
//   may be used to  endorse or promote  products derived  from this  software
Packit Service 3975d1
//   without specific prior written permission.
Packit Service 3975d1
//
Packit Service 3975d1
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit Service 3975d1
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO,  THE
Packit Service 3975d1
// IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit Service 3975d1
// ARE DISCLAIMED.  IN NO EVENT  SHALL THE COPYRIGHT OWNER  OR CONTRIBUTORS BE
Packit Service 3975d1
// LIABLE  FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR
Packit Service 3975d1
// CONSEQUENTIAL  DAMAGES  (INCLUDING,  BUT  NOT LIMITED  TO,  PROCUREMENT  OF
Packit Service 3975d1
// SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE,  DATA, OR PROFITS;  OR BUSINESS
Packit Service 3975d1
// INTERRUPTION)  HOWEVER CAUSED  AND ON ANY THEORY  OF LIABILITY,  WHETHER IN
Packit Service 3975d1
// CONTRACT,  STRICT LIABILITY,  OR TORT  (INCLUDING NEGLIGENCE  OR OTHERWISE)
Packit Service 3975d1
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  EVEN IF ADVISED OF THE
Packit Service 3975d1
// POSSIBILITY OF SUCH DAMAGE.
Packit Service 3975d1
Packit Service 3975d1
#ifndef __FPGAD_FPGAD_H__
Packit Service 3975d1
#define __FPGAD_FPGAD_H__
Packit Service 3975d1
Packit Service 3975d1
#ifndef __USE_GNU
Packit Service 3975d1
#define __USE_GNU
Packit Service 3975d1
#endif
Packit Service 3975d1
#ifndef _GNU_SOURCE
Packit Service 3975d1
#define _GNU_SOURCE
Packit Service 3975d1
#endif
Packit Service 3975d1
#include <stdlib.h>
Packit Service 3975d1
#include <stdbool.h>
Packit Service 3975d1
#include <stdint.h>
Packit Service 3975d1
#include <string.h>
Packit Service 3975d1
#include <pthread.h>
Packit Service 3975d1
#include <stdarg.h>
Packit Service 3975d1
#include <errno.h>
Packit Service 3975d1
#include <sys/stat.h>
Packit Service 3975d1
#include <fcntl.h>
Packit Service 3975d1
#include <signal.h>
Packit Service 3975d1
#include <opae/fpga.h>
Packit Service 3975d1
Packit Service 3975d1
#include "opae_int.h"
Packit Service 3975d1
Packit Service 3975d1
#include "api/logging.h"
Packit Service 3975d1
#include "command_line.h"
Packit Service 3975d1
Packit Service 3975d1
int daemonize(void (*hndlr)(int, siginfo_t *, void *),
Packit Service 3975d1
	      mode_t mask,
Packit Service 3975d1
	      const char *dir);
Packit Service 3975d1
Packit Service 3975d1
Packit Service 3975d1
#define fpgad_mutex_lock(__res, __mtx_ptr)                                     \
Packit Service 3975d1
	({                                                                     \
Packit Service 3975d1
		(__res) = pthread_mutex_lock(__mtx_ptr);                       \
Packit Service 3975d1
		if (__res)                                                     \
Packit Service 3975d1
			LOG("pthread_mutex_lock failed: %s",                   \
Packit Service 3975d1
				strerror(errno));                              \
Packit Service 3975d1
		__res;                                                         \
Packit Service 3975d1
	})
Packit Service 3975d1
Packit Service 3975d1
#define fpgad_mutex_unlock(__res, __mtx_ptr)                                   \
Packit Service 3975d1
	({                                                                     \
Packit Service 3975d1
		(__res) = pthread_mutex_unlock(__mtx_ptr);                     \
Packit Service 3975d1
		if (__res)                                                     \
Packit Service 3975d1
			LOG("pthread_mutex_unlock failed: %s",                 \
Packit Service 3975d1
					strerror(errno));                      \
Packit Service 3975d1
		__res;                                                         \
Packit Service 3975d1
	})
Packit Service 3975d1
Packit Service 3975d1
#endif /* __FPGAD_FPGAD_H__ */