Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/automation.h
- This file was added.
/*- | |||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | |||||
* | |||||
* Copyright (c) 2023 Hans Petter Selasky <hselasky@FreeBSD.org> | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
* | |||||
* $FreeBSD$ | |||||
*/ | |||||
#ifndef _SYS_AUTOMATION_H_ | |||||
#define _SYS_AUTOMATION_H_ | |||||
#include <sys/cdefs.h> | |||||
__WEAK(__start_set_automation); | |||||
__WEAK(__stop_set_automation); | |||||
#define __EXPORT_AUTOMATION(id,...) \ | |||||
static const id __section("set_automation") __used __aligned(1) = { __VA_ARGS__ } | |||||
/* | |||||
* The EXPORT_AUTOMATION() macro stores the C-string after the first | |||||
* identifier argument, into a special automation section. The strings | |||||
* in this section are later parsed by "sys/conf/automation.mk" . | |||||
* | |||||
* All NUL-characters are converted into newline characters. | |||||
* | |||||
* There is one command per line. | |||||
* | |||||
* Typical format: | |||||
* "command<space>argument(s)\n". | |||||
* | |||||
* Example: | |||||
* EXPORT_AUTOMATION(char xxx[], "sysinit global_variable"); | |||||
*/ | |||||
#define EXPORT_AUTOMATION(...) \ | |||||
__EXPORT_AUTOMATION(__VA_ARGS__) | |||||
#define EXPORT_HEX_DIGIT(x) \ | |||||
(((x) < 10) ? ('0' + (x)) : ('a' + (x) - 10)) | |||||
#define EXPORT_HEX_U8(x) \ | |||||
EXPORT_HEX_DIGIT(((x) >> 4) & 0xF), \ | |||||
EXPORT_HEX_DIGIT(((x) >> 0) & 0xF) | |||||
#define EXPORT_HEX_U16(x) \ | |||||
EXPORT_HEX_U8((x) >> 8), \ | |||||
EXPORT_HEX_U8((x) >> 0) | |||||
#define EXPORT_HEX_U32(x) \ | |||||
EXPORT_HEX_U16((x) >> 16), \ | |||||
EXPORT_HEX_U16((x) >> 0) | |||||
#endif /* _SYS_AUTOMATION_H_ */ |